]> git.itanic.dy.fi Git - linux-stable/commitdiff
mtd: core: check partition before dereference
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Mon, 25 Jul 2022 13:49:25 +0000 (22:49 +0900)
committerRichard Weinberger <richard@nod.at>
Mon, 1 Aug 2022 19:33:11 +0000 (21:33 +0200)
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
Reported-by: syzbot <syzbot+fe013f55a2814a9e8cfd@syzkaller.appspotmail.com>
Reported-by: kernel test robot <oliver.sang@intel.com>
Fixes: ad9b10d1eaada169 ("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>
drivers/mtd/mtdcore.c

index 6fafea80fd984f0fbd9330d58941c57e22e3e498..a9b8be9f40dc2706ec4c980cca7e2691f3939be5 100644 (file)
@@ -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)