mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mtd: lpddr2_nvm: i2c: mux: reg: Fix possible null-ptr-deref
@ 2022-11-14  2:01 Hui Tang
  2022-11-14  8:04 ` Miquel Raynal
  0 siblings, 1 reply; 3+ messages in thread
From: Hui Tang @ 2022-11-14  2:01 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, u.kleine-koenig
  Cc: linux-mtd, linux-kernel, weiyongjun1, yusongping

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")
Signed-off-by: Hui Tang <tanghui20@huawei.com>
---
 drivers/mtd/lpddr/lpddr2_nvm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mtd/lpddr/lpddr2_nvm.c b/drivers/mtd/lpddr/lpddr2_nvm.c
index 367e2d906de0..cf8e86eb4b2c 100644
--- a/drivers/mtd/lpddr/lpddr2_nvm.c
+++ b/drivers/mtd/lpddr/lpddr2_nvm.c
@@ -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 (IS_ERR(add_range))
+		return -ENODEV;
 
 	/* Populate map_info data structure */
 	*map = (struct map_info) {
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-14  8:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-14  2:01 [PATCH] mtd: lpddr2_nvm: i2c: mux: reg: Fix possible null-ptr-deref Hui Tang
2022-11-14  8:04 ` Miquel Raynal
2022-11-14  8:30   ` Hui Tang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®