linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mtd: lpddr2_nvm: Fix possible null-ptr-deref
@ 2022-11-14  9:02 Hui Tang
  2022-11-14  9:30 ` Uwe Kleine-König
  2022-11-17 21:16 ` Miquel Raynal
  0 siblings, 2 replies; 3+ messages in thread
From: Hui Tang @ 2022-11-14  9:02 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>
---
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(+)

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


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH v2] mtd: lpddr2_nvm: Fix possible null-ptr-deref
  2022-11-14  9:02 [PATCH v2] mtd: lpddr2_nvm: Fix possible null-ptr-deref Hui Tang
@ 2022-11-14  9:30 ` Uwe Kleine-König
  2022-11-17 21:16 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2022-11-14  9:30 UTC (permalink / raw)
  To: Hui Tang
  Cc: miquel.raynal, richard, vigneshr, linux-mtd, linux-kernel,
	weiyongjun1, yusongping


[-- Attachment #1.1: Type: text/plain, Size: 543 bytes --]

On Mon, Nov 14, 2022 at 05:02:40PM +0800, Hui Tang wrote:
> 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>

Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Thanks
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 144 bytes --]

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH v2] mtd: lpddr2_nvm: Fix possible null-ptr-deref
  2022-11-14  9:02 [PATCH v2] mtd: lpddr2_nvm: Fix possible null-ptr-deref Hui Tang
  2022-11-14  9:30 ` Uwe Kleine-König
@ 2022-11-17 21:16 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2022-11-17 21:16 UTC (permalink / raw)
  To: Hui Tang, miquel.raynal, richard, vigneshr, u.kleine-koenig
  Cc: linux-mtd, linux-kernel, weiyongjun1, yusongping

On Mon, 2022-11-14 at 09:02:40 UTC, Hui Tang wrote:
> 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>
> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

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] 3+ messages in thread

end of thread, other threads:[~2022-11-17 21:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-14  9:02 [PATCH v2] mtd: lpddr2_nvm: Fix possible null-ptr-deref Hui Tang
2022-11-14  9:30 ` Uwe Kleine-König
2022-11-17 21: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).