* [PATCH] mtd: physmap-core: Fix NULL pointer dereferencing in of_select_probe_type()
@ 2022-07-27 6:03 Zeng Jingxiang
2022-09-19 16:16 ` Miquel Raynal
0 siblings, 1 reply; 2+ messages in thread
From: Zeng Jingxiang @ 2022-07-27 6:03 UTC (permalink / raw)
To: miquel.raynal, richard, vigneshr; +Cc: linux-mtd, linux-kernel, Zeng Jingxiang
From: Zeng Jingxiang <linuszeng@tencent.com>
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>
---
drivers/mtd/maps/physmap-core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/mtd/maps/physmap-core.c b/drivers/mtd/maps/physmap-core.c
index 4f63b8430c71..69d0ab1f6f94 100644
--- a/drivers/mtd/maps/physmap-core.c
+++ b/drivers/mtd/maps/physmap-core.c
@@ -307,6 +307,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;
--
2.27.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mtd: physmap-core: Fix NULL pointer dereferencing in of_select_probe_type()
2022-07-27 6:03 [PATCH] mtd: physmap-core: Fix NULL pointer dereferencing in of_select_probe_type() Zeng Jingxiang
@ 2022-09-19 16:16 ` Miquel Raynal
0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2022-09-19 16:16 UTC (permalink / raw)
To: Zeng Jingxiang, miquel.raynal, richard, vigneshr
Cc: linux-mtd, linux-kernel, Zeng Jingxiang
On Wed, 2022-07-27 at 06:03:02 UTC, Zeng Jingxiang wrote:
> From: Zeng Jingxiang <linuszeng@tencent.com>
>
> 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>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-19 16:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-27 6:03 [PATCH] mtd: physmap-core: Fix NULL pointer dereferencing in of_select_probe_type() Zeng Jingxiang
2022-09-19 16:16 ` Miquel Raynal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).