Skip to content

Commit

Permalink
mtd: core: check partition before dereference
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tetsuo Handa authored and Richard Weinberger committed Aug 1, 2022
1 parent 9661524 commit 7ec4cdb
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/mtd/mtdcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ static void mtd_check_of_node(struct mtd_info *mtd)
return;

/* Check if a partitions node exist */
if (!mtd_is_partition(mtd))
return;
parent = mtd->parent;
parent_dn = dev_of_node(&parent->dev);
if (!parent_dn)
Expand Down

0 comments on commit 7ec4cdb

Please sign in to comment.