[PATCH] USB Network driver infrastructure: Fix leak when usb_autopm_get_interface() returns less than zero in kevent().

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We'll leak the memory allocated to 'urb' in 
drivers/net/usb/usbnet.c:kevent() when we 'goto fail_lowmem' and the 'urb' 
variable goes out of scope while still completely unused.

Signed-off-by: Jesper Juhl <jj@xxxxxxxxxxxxx>
---
 usbnet.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

 compile tested only.

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index ed9a416..95c41d5 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -931,8 +931,10 @@ fail_halt:
 		if (urb != NULL) {
 			clear_bit (EVENT_RX_MEMORY, &dev->flags);
 			status = usb_autopm_get_interface(dev->intf);
-			if (status < 0)
+			if (status < 0) {
+				usb_free_urb(urb);
 				goto fail_lowmem;
+			}
 			if (rx_submit (dev, urb, GFP_KERNEL) == -ENOLINK)
 				resched = 0;
 			usb_autopm_put_interface(dev->intf);


-- 
Jesper Juhl <jj@xxxxxxxxxxxxx>            http://www.chaosbits.net/
Plain text mails only, please.
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html

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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux