diff mbox

[1/1] USB: core: Free the allocated memory before exiting on error

Message ID 1353475879-30450-1-git-send-email-sachin.kamat@linaro.org
State Accepted
Headers show

Commit Message

Sachin Kamat Nov. 21, 2012, 5:31 a.m. UTC
'new_interfaces' should be freed to avoid memory leak.

Cc: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/usb/core/message.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Comments

Alan Stern Nov. 21, 2012, 2:57 p.m. UTC | #1
On Wed, 21 Nov 2012, Sachin Kamat wrote:

> 'new_interfaces' should be freed to avoid memory leak.
> 
> Cc: Sarah Sharp <sarah.a.sharp@linux.intel.com>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> ---
>  drivers/usb/core/message.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
> index a557658..1653f56 100644
> --- a/drivers/usb/core/message.c
> +++ b/drivers/usb/core/message.c
> @@ -1795,7 +1795,8 @@ free_interfaces:
>  	if (dev->actconfig && usb_disable_lpm(dev)) {
>  		dev_err(&dev->dev, "%s Failed to disable LPM\n.", __func__);
>  		mutex_unlock(hcd->bandwidth_mutex);
> -		return -ENOMEM;
> +		ret = -ENOMEM;
> +		goto free_interfaces;
>  	}
>  	ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL);
>  	if (ret < 0) {

Good catch, thank you.

Acked-by: Alan Stern <stern@rowland.harvard.edu>
diff mbox

Patch

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index a557658..1653f56 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1795,7 +1795,8 @@  free_interfaces:
 	if (dev->actconfig && usb_disable_lpm(dev)) {
 		dev_err(&dev->dev, "%s Failed to disable LPM\n.", __func__);
 		mutex_unlock(hcd->bandwidth_mutex);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto free_interfaces;
 	}
 	ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL);
 	if (ret < 0) {