[PATCH v2] mtd: phram: error handling
Saurabh Sengar
saurabh.truth at gmail.com
Sun Nov 8 22:23:18 PST 2015
registering the device with NULL pointer can lead to crash,
hence fixing it
Signed-off-by: Saurabh Sengar <saurabh.truth at gmail.com>
---
> Andy Shevchenko wrote:
> Hmm… Why not just checking it before an register attempt? I think user
> is in right to know as many problems as they have at one shot, with
> your patch if there are two problems the user has to try twice.
Yes, taken your feedback, fixing it here in v2 as you recommended
drivers/mtd/devices/phram.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index 8b66e52..46b7a8a 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -257,6 +257,9 @@ static int phram_setup(const char *val)
parse_err("illegal device length\n");
}
+ if(!name)
+ return -EINVAL;
+
ret = register_device(name, start, len);
if (!ret)
pr_info("%s device: %#llx at %#llx\n", name, len, start);
--
1.9.1
More information about the linux-mtd
mailing list