LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] USB Network driver infrastructure: Fix leak when usb_autopm_get_interface() returns less than zero in kevent().
@ 2011-02-10 20:58 Jesper Juhl
  2011-02-13 19:21 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Jesper Juhl @ 2011-02-10 20:58 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-usb, netdev, Greg Kroah-Hartman, David Brownell, David Hollis

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@chaosbits.net>
---
 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@chaosbits.net>            http://www.chaosbits.net/
Plain text mails only, please.
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] USB Network driver infrastructure: Fix leak when usb_autopm_get_interface() returns less than zero in kevent().
  2011-02-10 20:58 [PATCH] USB Network driver infrastructure: Fix leak when usb_autopm_get_interface() returns less than zero in kevent() Jesper Juhl
@ 2011-02-13 19:21 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-02-13 19:21 UTC (permalink / raw)
  To: jj; +Cc: linux-kernel, linux-usb, netdev, gregkh, dbrownell, dhollis

From: Jesper Juhl <jj@chaosbits.net>
Date: Thu, 10 Feb 2011 21:58:45 +0100 (CET)

> 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@chaosbits.net>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-02-13 19:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-10 20:58 [PATCH] USB Network driver infrastructure: Fix leak when usb_autopm_get_interface() returns less than zero in kevent() Jesper Juhl
2011-02-13 19:21 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).