lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1302017802-16614-5-git-send-email-roger.quadros@nokia.com>
Date:	Tue,  5 Apr 2011 18:36:41 +0300
From:	Roger Quadros <roger.quadros@...ia.com>
To:	gregkh@...e.de
Cc:	mina86@...a86.com, linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH 4/5] usb: gadget: f_mass_storage: Fix potential memory leak

If allocation of multiple buffers would fail then we would leak memory.
Fix that.

Signed-off-by: Roger Quadros <roger.quadros@...ia.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ