From patchwork Fri Jun 24 20:05:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jassi Brar X-Patchwork-Id: 2315 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 8940123F6D for ; Fri, 24 Jun 2011 20:05:45 +0000 (UTC) Received: from mail-qy0-f180.google.com (mail-qy0-f180.google.com [209.85.216.180]) by fiordland.canonical.com (Postfix) with ESMTP id 56F82A18169 for ; Fri, 24 Jun 2011 20:05:45 +0000 (UTC) Received: by qyk30 with SMTP id 30so2258363qyk.11 for ; Fri, 24 Jun 2011 13:05:44 -0700 (PDT) Received: by 10.229.117.95 with SMTP id p31mr2871957qcq.97.1308945944730; Fri, 24 Jun 2011 13:05:44 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.230.139 with SMTP id jm11cs58474qcb; Fri, 24 Jun 2011 13:05:44 -0700 (PDT) Received: by 10.236.185.163 with SMTP id u23mr6429172yhm.177.1308945944216; Fri, 24 Jun 2011 13:05:44 -0700 (PDT) Received: from mail-pv0-f178.google.com (mail-pv0-f178.google.com [74.125.83.178]) by mx.google.com with ESMTPS id g63si17100762yhn.28.2011.06.24.13.05.43 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 24 Jun 2011 13:05:44 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.178 is neither permitted nor denied by best guess record for domain of jaswinder.singh@linaro.org) client-ip=74.125.83.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.83.178 is neither permitted nor denied by best guess record for domain of jaswinder.singh@linaro.org) smtp.mail=jaswinder.singh@linaro.org Received: by mail-pv0-f178.google.com with SMTP id 7so2219038pvg.37 for ; Fri, 24 Jun 2011 13:05:43 -0700 (PDT) Received: by 10.68.56.132 with SMTP id a4mr1904972pbq.89.1308945943020; Fri, 24 Jun 2011 13:05:43 -0700 (PDT) Received: from localhost.localdomain ([122.167.86.144]) by mx.google.com with ESMTPS id v6sm2280959pbh.70.2011.06.24.13.05.38 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 24 Jun 2011 13:05:41 -0700 (PDT) From: Jassi Brar To: linux-usb@vger.kernel.org Cc: stern@rowland.harvard.edu, laurent.pinchart@ideasonboard.com, gregkh@suse.de, patches@linaro.org, balbi@ti.com, ti@lists.linaro.org, Jassi Brar Subject: [PATCH 3/3] USB: Gadget: Webcam: Free resources in config unbind Date: Sat, 25 Jun 2011 01:35:34 +0530 Message-Id: <1308945934-758-1-git-send-email-jaswinder.singh@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1308945851-607-1-git-send-email-jaswinder.singh@linaro.org> References: <1308945851-607-1-git-send-email-jaswinder.singh@linaro.org> Resources allocated during configuration 'bind' should be freed in configuration 'unbind'. Signed-off-by: Jassi Brar --- drivers/usb/gadget/f_uvc.c | 12 ++++++++++-- drivers/usb/gadget/webcam.c | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/f_uvc.c b/drivers/usb/gadget/f_uvc.c index c847b9e..ee3ed4f 100644 --- a/drivers/usb/gadget/f_uvc.c +++ b/drivers/usb/gadget/f_uvc.c @@ -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"); diff --git a/drivers/usb/gadget/webcam.c b/drivers/usb/gadget/webcam.c index a5a0fdb..c3ffb3d 100644 --- a/drivers/usb/gadget/webcam.c +++ b/drivers/usb/gadget/webcam.c @@ -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,