All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB NET KL5KUSB101: Fix mem leak in error path of kaweth_download_firmware()
@ 2011-01-23 22:19 Jesper Juhl
  2011-01-25  7:20 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Jesper Juhl @ 2011-01-23 22:19 UTC (permalink / raw)
  To: linux-usb
  Cc: linux-kernel, netdev, Greg Kroah-Hartman, The Zapman, Michael Rothwell

We will leak the storage allocated by request_firmware() if the size of 
the firmware is greater than KAWETH_FIRMWARE_BUF_SIZE.
This removes the leak by calling release_firmware() before we return 
-ENOSPC.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 kaweth.c |    1 +
 1 file changed, 1 insertion(+)

  Compile tested only since I do not have the hardware.

diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index 5e98643..7dc8497 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -406,6 +406,7 @@ static int kaweth_download_firmware(struct kaweth_device *kaweth,
 
 	if (fw->size > KAWETH_FIRMWARE_BUF_SIZE) {
 		err("Firmware too big: %zu", fw->size);
+		release_firmware(fw);
 		return -ENOSPC;
 	}
 	data_len = fw->size;


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


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

* Re: [PATCH] USB NET KL5KUSB101: Fix mem leak in error path of kaweth_download_firmware()
  2011-01-23 22:19 [PATCH] USB NET KL5KUSB101: Fix mem leak in error path of kaweth_download_firmware() Jesper Juhl
@ 2011-01-25  7:20 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-01-25  7:20 UTC (permalink / raw)
  To: jj; +Cc: linux-usb, linux-kernel, netdev, gregkh, zapman, rothwell

From: Jesper Juhl <jj@chaosbits.net>
Date: Sun, 23 Jan 2011 23:19:55 +0100 (CET)

> We will leak the storage allocated by request_firmware() if the size of 
> the firmware is greater than KAWETH_FIRMWARE_BUF_SIZE.
> This removes the leak by calling release_firmware() before we return 
> -ENOSPC.
> 
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>

Applied, thanks Jesper.

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

end of thread, other threads:[~2011-01-25  7:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-23 22:19 [PATCH] USB NET KL5KUSB101: Fix mem leak in error path of kaweth_download_firmware() Jesper Juhl
2011-01-25  7:20 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.