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
559559 return;
560560
561561 /* Check if a partitions node exist */
562+ if (!mtd_is_partition(mtd))
563+ return;
562564 parent = mtd->parent;
563565 parent_dn = dev_of_node(&parent->dev);
564566 if (!parent_dn)