[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1446972440-3795-1-git-send-email-saurabh.truth@gmail.com>
Date: Sun, 8 Nov 2015 14:17:20 +0530
From: Saurabh Sengar <saurabh.truth@...il.com>
To: joern@...ybastard.org, dwmw2@...radead.org,
computersforpeace@...il.com, linux-mtd@...ts.infradead.org,
linux-kernel@...r.kernel.org
Cc: Saurabh Sengar <saurabh.truth@...il.com>
Subject: [PATCH] mtd: phram: error handling
registering the device with NULL pointer can lead to crash,
hence fixing it.
Signed-off-by: Saurabh Sengar <saurabh.truth@...il.com>
---
in case of 'illegal start address' or 'illegal device length', name pointer is getting freed.
we shouldn't register the device with NULL pointer.
drivers/mtd/devices/phram.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index 8b66e52..9a7aed3 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -249,12 +249,14 @@ static int phram_setup(const char *val)
if (ret) {
kfree(name);
parse_err("illegal start address\n");
+ goto err;
}
ret = parse_num64(&len, token[2]);
if (ret) {
kfree(name);
parse_err("illegal device length\n");
+ goto err;
}
ret = register_device(name, start, len);
@@ -262,7 +264,7 @@ static int phram_setup(const char *val)
pr_info("%s device: %#llx at %#llx\n", name, len, start);
else
kfree(name);
-
+err:
return ret;
}
--
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