Skip to content

Commit 7ec4cdb

Browse files
Tetsuo Handarichardweinberger
authored andcommitted
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. Link: https://syzkaller.appspot.com/bug?extid=fe013f55a2814a9e8cfd [1] Reported-by: syzbot <syzbot+fe013f55a2814a9e8cfd@syzkaller.appspotmail.com> Reported-by: kernel test robot <oliver.sang@intel.com> Fixes: ad9b10d ("mtd: core: introduce of support for dynamic partitions") Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> CC: stable@vger.kernel.org Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent 9661524 commit 7ec4cdb

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/mtd/mtdcore.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,8 @@ static void mtd_check_of_node(struct mtd_info *mtd)
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)

0 commit comments

Comments
 (0)