From 40fa265fabc1ca8b6853f7e362c9ddfab4fbb018 Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Fri, 7 Feb 2014 09:48:54 +0100 Subject: [PATCH] mtd: core: avoid possible NULL ptr deref Signed-off-by: Lucas Stach Signed-off-by: Sascha Hauer --- drivers/mtd/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c index 6db1c6db3..3439a389a 100644 --- a/drivers/mtd/core.c +++ b/drivers/mtd/core.c @@ -404,7 +404,8 @@ int add_mtd_device(struct mtd_info *mtd, char *devname, int device_id) } devfs_create(&mtd->cdev); - of_parse_partitions(&mtd->cdev, mtd->parent->device_node); + if (mtd->parent) + of_parse_partitions(&mtd->cdev, mtd->parent->device_node); list_for_each_entry(hook, &mtd_register_hooks, hook) if (hook->add_mtd_device)