History

mtd: core: check partition before dereference

syzbot is reporting NULL pointer dereference at mtd_check_of_node() [1], for mtdram test device (CONFIG_MTD_MTDRAM) is not partition.

Tetsuo Handa committed 4 years ago

Commit 7ec4cdb1 parent 96615241 file · +2 −0Browse files

Unified · Split

drivers/mtd/mtdcore.c+2−0
@@ -559,6 +559,8 @@ static void mtd_check_of_node(struct mtd_info *mtd) · 558 unmodified lines
559 return;559 return;
560 560
561 /* Check if a partitions node exist */561 /* Check if a partitions node exist */
562 if (!mtd_is_partition(mtd))
563 return;
562 parent = mtd->parent;564 parent = mtd->parent;
563 parent_dn = dev_of_node(&parent->dev);565 parent_dn = dev_of_node(&parent->dev);
564 if (!parent_dn)566 if (!parent_dn)