]> git.karo-electronics.de Git - karo-tx-linux.git/commit
usb: gadget: uvc: fix error path in uvc_function_bind()
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Mon, 22 Oct 2012 20:15:05 +0000 (22:15 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 3 Jan 2013 03:33:01 +0000 (03:33 +0000)
commit1efa8a5aac93d9e67075995d7d4902b57ce184f7
tree9241f2d44624f4f2a0d798c1dcd3bea5c71bb6da
parentb7cd54c3440fb23e9f1b580cc5456a5a9d80eab2
usb: gadget: uvc: fix error path in uvc_function_bind()

commit 0f9df939385527049c8062a099fbfa1479fe7ce0 upstream.

The "video->minor = -1" assigment is done in V4L2 by
video_register_device() so it is removed here.
Now. uvc_function_bind() calls in error case uvc_function_unbind() for
cleanup. The problem is that uvc_function_unbind() frees the uvc struct
and uvc_bind_config() does as well in error case of usb_add_function().
Removing kfree() in usb_add_function() would make the patch smaller but
it would look odd because the new allocated memory is not cleaned up.
However it is not guaranteed that if we call usb_add_function() we also
get to the bind function.
Therefore the patch extracts the conditional cleanup from
uvc_function_unbind() applies to uvc_function_bind().
uvc_function_unbind() now contains only the complete cleanup which is
required once everything has been registrated.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/usb/gadget/f_uvc.c