[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1434443826-4929-124-git-send-email-lizf@kernel.org>
Date: Tue, 16 Jun 2015 16:36:18 +0800
From: lizf@...nel.org
To: stable@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
Sudip Mukherjee <sudipm.mukherjee@...il.com>,
Sudip Mukherjee <sudip@...torindia.org>,
Markus Pargmann <mpa@...gutronix.de>,
Zefan Li <lizefan@...wei.com>
Subject: [PATCH 3.4 124/172] nbd: fix possible memory leak
From: Sudip Mukherjee <sudipm.mukherjee@...il.com>
3.4.108-rc1 review patch. If anyone has any objections, please let me know.
------------------
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@...torindia.org>
Acked-by: Paul Clements <Paul.Clements@...elEye.com>
Signed-off-by: Markus Pargmann <mpa@...gutronix.de>
Signed-off-by: Zefan Li <lizefan@...wei.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 35fc569..eac3705 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -773,10 +773,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);
@@ -798,6 +794,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)
--
1.9.1
--
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