[PATCH] USB NET KL5KUSB101: Fix mem leak in error path of kaweth_download_firmware()

Subsystems: networking drivers, the rest, usb networking drivers

STALE5740d

2 messages, 2 authors, 2011-01-25 · open the first message on its own page

[PATCH] USB NET KL5KUSB101: Fix mem leak in error path of kaweth_download_firmware()

From: Jesper Juhl <hidden>
Date: 2011-01-23 22:19:33

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 <redacted>
---
 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.

Re: [PATCH] USB NET KL5KUSB101: Fix mem leak in error path of kaweth_download_firmware()

From: David Miller <davem@davemloft.net>
Date: 2011-01-25 07:20:03

From: Jesper Juhl <redacted>
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 <redacted>
Applied, thanks Jesper.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help