linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: phram: error handling
@ 2015-11-08  8:47 Saurabh Sengar
  2015-11-08 21:23 ` Andy Shevchenko
  0 siblings, 1 reply; 13+ messages in thread
From: Saurabh Sengar @ 2015-11-08  8:47 UTC (permalink / raw)
  To: joern, dwmw2, computersforpeace, linux-mtd, linux-kernel; +Cc: Saurabh Sengar

registering the device with NULL pointer can lead to crash,
hence fixing it.

Signed-off-by: Saurabh Sengar <saurabh.truth@gmail.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

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-11-12  6:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-08  8:47 [PATCH] mtd: phram: error handling Saurabh Sengar
2015-11-08 21:23 ` Andy Shevchenko
2015-11-09  6:23   ` [PATCH v2] " Saurabh Sengar
2015-11-10 18:20     ` Brian Norris
2015-11-10 18:33       ` [PATCH] " Joe Perches
2015-11-10 18:39         ` Brian Norris
2015-11-10 18:45           ` Joe Perches
2015-11-10 19:03             ` Brian Norris
2015-11-10 19:27               ` Saurabh Sengar
2015-11-10 19:41                 ` Brian Norris
2015-11-11  8:23                   ` Saurabh Sengar
2015-11-11 19:44                     ` Brian Norris
2015-11-12  6:23                       ` Saurabh Sengar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).