[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220727060302.1560325-1-zengjx95@gmail.com>
Date:   Wed, 27 Jul 2022 14:03:02 +0800
From:   Zeng Jingxiang <zengjx95@...il.com>
To:     miquel.raynal@...tlin.com, richard@....at, vigneshr@...com
Cc:     linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org,
        Zeng Jingxiang <linuszeng@...cent.com>
Subject: [PATCH] mtd: physmap-core: Fix NULL pointer dereferencing in of_select_probe_type()
From: Zeng Jingxiang <linuszeng@...cent.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@...cent.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
Powered by blists - more mailing lists
 
