All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesper Juhl <jj@chaosbits.net>
To: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@suse.de>,
	The Zapman <zapman@interlan.net>,
	Michael Rothwell <rothwell@interlan.net>
Subject: [PATCH] USB NET KL5KUSB101: Fix mem leak in error path of kaweth_download_firmware()
Date: Sun, 23 Jan 2011 23:19:55 +0100 (CET)	[thread overview]
Message-ID: <alpine.LNX.2.00.1101232315230.30955@swampdragon.chaosbits.net> (raw)

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.


             reply	other threads:[~2011-01-23 22:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-23 22:19 Jesper Juhl [this message]
2011-01-25  7:20 ` [PATCH] USB NET KL5KUSB101: Fix mem leak in error path of kaweth_download_firmware() David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LNX.2.00.1101232315230.30955@swampdragon.chaosbits.net \
    --to=jj@chaosbits.net \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rothwell@interlan.net \
    --cc=zapman@interlan.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.