diff options
author | Zeng Jingxiang <linuszeng@tencent.com> | 2022-07-27 08:03:02 +0200 |
---|---|---|
committer | Miquel Raynal <miquel.raynal@bootlin.com> | 2022-09-19 18:14:53 +0200 |
commit | 8b740c08eb8202817562c358e8d867db0f7d6565 (patch) | |
tree | 14cdf56ae7c23daa906139e4e4fa0e0cc01cc94a /drivers/mtd | |
parent | mtd: devices: docg3: check the return value of devm_ioremap() in the probe (diff) | |
download | linux-8b740c08eb8202817562c358e8d867db0f7d6565.tar.xz linux-8b740c08eb8202817562c358e8d867db0f7d6565.zip |
mtd: physmap-core: Fix NULL pointer dereferencing in of_select_probe_type()
Coverity complains of a possible NULL dereference:
in of_select_probe_type():
1. returned_null: of_match_device() returns NULL.
2. var_assigned: match = NULL return value from of_match_device()
309 match = of_match_device(of_flash_match, &dev->dev);
3.dereference: Dereferencing the NULL pointer match.
310 probe_type = match->data;
Signed-off-by: Zeng Jingxiang <linuszeng@tencent.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220727060302.1560325-1-zengjx95@gmail.com
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/maps/physmap-core.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/mtd/maps/physmap-core.c b/drivers/mtd/maps/physmap-core.c index 85eca6a192e6..c73854da5136 100644 --- a/drivers/mtd/maps/physmap-core.c +++ b/drivers/mtd/maps/physmap-core.c @@ -300,6 +300,9 @@ static const char *of_select_probe_type(struct platform_device *dev) const char *probe_type; match = of_match_device(of_flash_match, &dev->dev); + if (!match) + return NULL; + probe_type = match->data; if (probe_type) return probe_type; |