Skip to contentSkip to conversation

NBD fixes

GIT PULL New Markus Pargmann 1 participant 2 messages Feb 12, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi Jens,

This is a pull request for one NBD patch. It fixes a memory leak which occures when a module parameter has an invalid value.

It is based on v3.19-rc2. If you prefer a different base please let me know.

Best Regards,

Markus

The following changes since commit b7392d2247cfe6771f95d256374f1a8e6a6f48d6:

Linux 3.19-rc2 (2014-12-28 16:49:37 -0800)

are available in the git repository at:

git://git.pengutronix.de/git/mpa/linux-nbd.git tags/nbd_fixes_20150212

for you to fetch changes up to 473b3bfe169ca0b2192d7184786429bd75d359da:

nbd: fix possible memory leak (2015-02-12 13:21:55 +0100)

----------------------------------------------------------------
NBD fixes based on v3.19-rc2

----------------------------------------------------------------
Sudip Mukherjee (1):
nbd: fix possible memory leak

 drivers/block/nbd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 nbd: fix possible memory leak

From: Sudip Mukherjee <[email protected]>

we have already allocated memory for nbd_dev, but we were not releasing that memory and just returning the error value.

---
 drivers/block/nbd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/block/nbd.c +4 -4
index 4bc2a5cb9935..a98c41f72c63 100644
@@ -803,10 +803,6 @@ static int __init nbd_init(void)
 		return -EINVAL;
 	}
 
-	nbd_dev = kcalloc(nbds_max, sizeof(*nbd_dev), GFP_KERNEL);
-	if (!nbd_dev)
-		return -ENOMEM;
-
 	part_shift = 0;
 	if (max_part > 0) {
 		part_shift = fls(max_part);
@@ -828,6 +824,10 @@ static int __init nbd_init(void)
 	if (nbds_max > 1UL << (MINORBITS - part_shift))
 		return -EINVAL;
 
+	nbd_dev = kcalloc(nbds_max, sizeof(*nbd_dev), GFP_KERNEL);
+	if (!nbd_dev)
+		return -ENOMEM;
+
 	for (i = 0; i < nbds_max; i++) {
 		struct gendisk *disk = alloc_disk(1 << part_shift);
 		if (!disk)
Signature · 1 line
2.1.4