From: Roger Quadros <roger.quadros@nokia.com>
To: gregkh@suse.de
Cc: mina86@mina86.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 4/5] usb: gadget: f_mass_storage: Fix potential memory leak
Date: Tue, 5 Apr 2011 18:36:41 +0300 [thread overview]
Message-ID: <1302017802-16614-5-git-send-email-roger.quadros@nokia.com> (raw)
In-Reply-To: <1302017802-16614-1-git-send-email-roger.quadros@nokia.com>
If allocation of multiple buffers would fail then we would leak memory.
Fix that.
Signed-off-by: Roger Quadros <roger.quadros@nokia.com>
---
drivers/usb/gadget/f_mass_storage.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index f6bd001..60b4df9 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -2863,6 +2863,12 @@ buffhds_first_it:
bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL);
if (unlikely(!bh->buf)) {
rc = -ENOMEM;
+ /* clean up */
+ while (i < FSG_NUM_BUFFERS) {
+ bh--;
+ kfree(bh->buf);
+ i++;
+ }
goto error_release;
}
} while (--i);
--
1.6.0.4
next prev parent reply other threads:[~2011-04-05 15:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-05 15:36 [PATCH 0/5] fixes for f_mass_storage Roger Quadros
2011-04-05 15:36 ` [PATCH 1/5] usb: gadget: f_mass_storage: Fix Bulk-only RESET handling Roger Quadros
2011-04-05 16:09 ` Michal Nazarewicz
2011-04-05 15:36 ` [PATCH 2/5] usb: gadget: f_mass_storage: If 'ro'/'cdrom' specified, open file as read-only Roger Quadros
2011-04-05 16:04 ` Michal Nazarewicz
2011-04-05 15:36 ` [PATCH 3/5] usb: gadget: f_mass_storage: Prevent NULL pointer dereference Roger Quadros
2011-04-05 15:56 ` Michal Nazarewicz
2011-04-05 17:47 ` Roger Quadros
2011-04-05 15:36 ` Roger Quadros [this message]
2011-04-05 15:59 ` [PATCH 4/5] usb: gadget: f_mass_storage: Fix potential memory leak Michal Nazarewicz
2011-04-05 17:47 ` Roger Quadros
2011-04-05 15:36 ` [PATCH 5/5] usb: gadget: f_mass_storage: remove unnecessary initialization Roger Quadros
2011-04-05 16:01 ` Michal Nazarewicz
2011-04-05 16:10 ` [PATCH 0/5] fixes for f_mass_storage Michal Nazarewicz
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=1302017802-16614-5-git-send-email-roger.quadros@nokia.com \
--to=roger.quadros@nokia.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mina86@mina86.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®