Skip to contentSkip to conversation

mtd: lpddr2_nvm: Fix possible null-ptr-deref

PATCH Applied Hui Tang 3 participants 3 messages Nov 14, 2022 – Nov 17, 2022 Memory technology devices (MTD)

lore
Share & tools
lore

Hui Tang

author
#0 lore raw

PATCH v2 1/1 mtd: lpddr2_nvm: Fix possible null-ptr-deref

It will cause null-ptr-deref when resource_size(add_range) invoked, if platform_get_resource() returns NULL.

Fixes 96ba9dd65788 ("mtd: lpddr: add driver for LPDDR2-NVM PCM memories")

---
v1 -> v2:
- replace IS_ERR(add_range) with !add_range
- fix commit subject format

---
 drivers/mtd/lpddr/lpddr2_nvm.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mtd/lpddr/lpddr2_nvm.c +2 -0
index 367e2d906de0..e71af4c49096 100644
@@ -433,6 +433,8 @@ static int lpddr2_nvm_probe(struct platform_device *pdev)
 
 	/* lpddr2_nvm address range */
 	add_range = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!add_range)
+		return -ENODEV;
 
 	/* Populate map_info data structure */
 	*map = (struct map_info) {
Signature · 1 line
2.17.1
Acked-by on v2 1/1
#1 lore raw
Quoted 5 lines · Hui Tang

It will cause null-ptr-deref when resource_size(add_range) invoked, if platform_get_resource() returns NULL.

Fixes 96ba9dd65788 ("mtd: lpddr: add driver for LPDDR2-NVM PCM memories")

Thanks
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
maintainer Applied
#2 lore raw
In reply to Hui Tang
Quoted 6 lines · Hui Tang

It will cause null-ptr-deref when resource_size(add_range) invoked, if platform_get_resource() returns NULL.

Fixes 96ba9dd65788 ("mtd: lpddr: add driver for LPDDR2-NVM PCM memories")

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/