USB NET KL5KUSB101: Fix mem leak in error path of kaweth_download_firmware()
authorJesper Juhl <jj@chaosbits.net>
Sun, 23 Jan 2011 12:19:55 +0000 (12:19 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 25 Jan 2011 07:20:24 +0000 (23:20 -0800)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/kaweth.c

index 5e98643..7dc8497 100644 (file)
@@ -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;