[PATCH 12/14] mtd: core: avoid possible NULL ptr deref

Lucas Stach dev at lynxeye.de
Fri Feb 7 03:48:54 EST 2014


Signed-off-by: Lucas Stach <dev at lynxeye.de>
---
 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 6db1c6d..3439a38 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)
-- 
1.8.5.3




More information about the barebox mailing list