[3.16.y-ckt stable] Patch "nbd: fix possible memory leak" has been added to staging queue
Luis Henriques
luis.henriques at canonical.com
Thu Apr 9 08:58:00 UTC 2015
This is a note to let you know that I have just added a patch titled
nbd: fix possible memory leak
to the linux-3.16.y-queue branch of the 3.16.y-ckt extended stable tree
which can be found at:
http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.16.y-queue
This patch is scheduled to be released in version 3.16.7-ckt10.
If you, or anyone else, feels it should not be added to this tree, please
reply to this email.
For more information about the 3.16.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable
Thanks.
-Luis
------
>From d762b1fde5c412b9039b002d367358b75ed36546 Mon Sep 17 00:00:00 2001
From: Sudip Mukherjee <sudipm.mukherjee at gmail.com>
Date: Tue, 27 Jan 2015 18:08:22 +0530
Subject: nbd: fix possible memory leak
commit ff6b8090e26ef7649ef0cc6b42389141ef48b0cf upstream.
we have already allocated memory for nbd_dev, but we were not
releasing that memory and just returning the error value.
Signed-off-by: Sudip Mukherjee <sudip at vectorindia.org>
Acked-by: Paul Clements <Paul.Clements at SteelEye.com>
Signed-off-by: Markus Pargmann <mpa at pengutronix.de>
Signed-off-by: Luis Henriques <luis.henriques at canonical.com>
---
drivers/block/nbd.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index fb31b8ee4372..30f0ec65415f 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -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)
More information about the kernel-team
mailing list