@@ -481,8 +481,6 @@ uvc_function_unbind(struct usb_configuration *c, struct usb_function *f)
kfree(f->descriptors);
kfree(f->hs_descriptors);
-
- kfree(uvc);
}
static int __init
@@ -648,6 +646,8 @@ uvc_bind_config(struct usb_configuration *c,
ret = usb_add_function(c, &uvc->func);
if (ret)
kfree(uvc);
+ else
+ c->data = (void *)uvc;
return ret;
@@ -656,6 +656,14 @@ error:
return ret;
}
+void __exit uvc_unbind_config(struct usb_configuration *c)
+{
+ struct uvc_device *uvc = c->data;
+
+ kfree(uvc);
+ c->data = NULL;
+}
+
module_param_named(trace, uvc_gadget_trace_param, uint, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(trace, "Trace level bitmask");
@@ -317,6 +317,7 @@ webcam_config_bind(struct usb_configuration *c)
static struct usb_configuration webcam_config_driver = {
.label = webcam_config_label,
+ .unbind = uvc_unbind_config,
.bConfigurationValue = 1,
.iConfiguration = 0, /* dynamic */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
Resources allocated during configuration 'bind' should be freed in configuration 'unbind'. Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org> --- drivers/usb/gadget/f_uvc.c | 12 ++++++++++-- drivers/usb/gadget/webcam.c | 1 + 2 files changed, 11 insertions(+), 2 deletions(-)