diff options
| author | Tetsuo Handa <[email protected]> | 2022-07-25 13:49:25 +0000 |
|---|---|---|
| committer | Richard Weinberger <[email protected]> | 2022-08-01 19:33:11 +0000 |
| commit | 7ec4cdb321738d44ae5d405e7b6ac73dfbf99caa (patch) | |
| tree | 46b80b2017aec2031048be5fe6068ed234855560 | |
| parent | Merge tag 'spi-nor/for-5.20' into mtd/next (diff) | |
| download | kernel-7ec4cdb321738d44ae5d405e7b6ac73dfbf99caa.tar.gz kernel-7ec4cdb321738d44ae5d405e7b6ac73dfbf99caa.zip | |
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 <[email protected]>
Reported-by: kernel test robot <[email protected]>
Fixes: ad9b10d1eaada169 ("mtd: core: introduce of support for dynamic partitions")
Signed-off-by: Tetsuo Handa <[email protected]>
CC: [email protected]
Signed-off-by: Richard Weinberger <[email protected]>
| -rw-r--r-- | drivers/mtd/mtdcore.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 6fafea80fd98..a9b8be9f40dc 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -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) |
