diff mbox

usbnet: fix memory leak in usbnet_disconnect()

Message ID AANLkTintuq7z45e-Cr8Ma5_Bm+UtnO+Gsysn6A3kv+CZ@mail.gmail.com
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

DMITRIY GRUZMAN March 21, 2011, 9:49 p.m. UTC
usb_probe() allocates memory for transfer buffer and urb and this
memory was not properly released in usbnet_disconnect().   The issue
was found and the fix was recommended by Fu-Lei Tian and Jun-Xiao
Chang.

Signed-off-by: Dmitriy Gruzman <xmb836@motorola.com>
---
 drivers/net/usb/usbnet.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

 				usb_pipeendpoint(pipe), maxp, period);
@@ -1237,6 +1238,7 @@ void usbnet_disconnect (struct usb_interface *intf)
 	if (dev->driver_info->unbind)
 		dev->driver_info->unbind (dev, intf);

+	usb_free_urb(dev->interrupt);
 	free_netdev(net);
 	usb_put_dev (xdev);
 }

Comments

David Miller March 28, 2011, 1:11 a.m. UTC | #1
From: DMITRIY GRUZMAN <xmb836@motorola.com>
Date: Mon, 21 Mar 2011 16:49:50 -0500

> usb_probe() allocates memory for transfer buffer and urb and this
> memory was not properly released in usbnet_disconnect().   The issue
> was found and the fix was recommended by Fu-Lei Tian and Jun-Xiao
> Chang.
> 
> Signed-off-by: Dmitriy Gruzman <xmb836@motorola.com>

Your email client corrupted your patch, among other things:

> @@ -210,6 +210,7 @@ static int init_status (struct usbnet *dev, struct
> usb_interface *intf)

it chopped up long lines.

Please fix this up, test your setup by emailing the patch to yourself
and trying to apply what you receive, then try submitting it here
freshly again.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Nicolas de Pesloüan March 28, 2011, 8:01 p.m. UTC | #2
Le 28/03/2011 03:11, David Miller a écrit :
> From: DMITRIY GRUZMAN<xmb836@motorola.com>
> Date: Mon, 21 Mar 2011 16:49:50 -0500
>
>> usb_probe() allocates memory for transfer buffer and urb and this
>> memory was not properly released in usbnet_disconnect().   The issue
>> was found and the fix was recommended by Fu-Lei Tian and Jun-Xiao
>> Chang.
>>
>> Signed-off-by: Dmitriy Gruzman<xmb836@motorola.com>
>
> Your email client corrupted your patch, among other things:
>
>> @@ -210,6 +210,7 @@ static int init_status (struct usbnet *dev, struct
>> usb_interface *intf)
>
> it chopped up long lines.
>
> Please fix this up, test your setup by emailing the patch to yourself
> and trying to apply what you receive, then try submitting it here
> freshly again.
>
> Thanks.

This nice advice should be inserted into Documentation/SubmittingPatch.

	Nicolas.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index c04d49e..67a5728 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -210,6 +210,7 @@  static int init_status (struct usbnet *dev, struct
usb_interface *intf)
 		} else {
 			usb_fill_int_urb(dev->interrupt, dev->udev, pipe,
 				buf, maxp, intr_complete, dev, period);
+			dev->interrupt->transfer_flags |= URB_FREE_BUFFER;
 			dev_dbg(&intf->dev,
 				"status ep%din, %d bytes period %d\n",