mtd: lpddr2_nvm: i2c: mux: reg: Fix possible null-ptr-deref
PATCH 1/1 mtd: lpddr2_nvm: i2c: mux: reg: Fix possible null-ptr-deref
It will cause null-ptr-deref when resource_size(add_range) invoked, if platform_get_resource() returns NULL.
--- drivers/mtd/lpddr/lpddr2_nvm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mtd/lpddr/lpddr2_nvm.c +2 -0
@@ -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 ) {
Signature · 1 line
2.17.1
Miquel Raynal
maintainerHi Hui,
[email protected] wrote on Mon, 14 Nov 2022 10:01:41 +0800:
Quoted 14 lines
It will cause null-ptr-deref when
resource_size(add_range)invoked, ifplatform_get_resource()returns NULL.Fixes 96ba9dd65788 ("mtd: lpddr: add driver for LPDDR2-NVM PCM memories")Signed-off-by Hui Tang <[email protected]>--- drivers/mtd/lpddr/lpddr2_nvm.c | 2 ++ 1 file changed, 2 insertions(+)drivers/mtd/lpddr/lpddr2_nvm.c +0
-0
drivers/mtd/lpddr/lpddr2_nvm.c static int lpddr2_nvm_probe(struct platform_device *pdev) · line 436
Quoted 4 lines
drivers/mtd/lpddr/lpddr2_nvm.c +1
-0@@ -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))
platform_get_resource() just returns NULL upon error.
drivers/mtd/lpddr/lpddr2_nvm.c static int lpddr2_nvm_probe(struct platform_device *pdev) · line 440
Quoted 4 lines
drivers/mtd/lpddr/lpddr2_nvm.c +1
-0+return -ENODEV ;/* Populate map_info data structure */ *map = (struct map_info ) {
Thanks,
Miquèl
Quoted 19 lines · Miquel Raynal
Hi Hui,
[email protected] wrote on Mon, 14 Nov 2022 10:01:41 +0800:
Quoted 15 lines
It will cause null-ptr-deref when
resource_size(add_range)invoked, ifplatform_get_resource()returns NULL.Fixes 96ba9dd65788 ("mtd: lpddr: add driver for LPDDR2-NVM PCM memories")Signed-off-by Hui Tang <[email protected]>--- drivers/mtd/lpddr/lpddr2_nvm.c | 2 ++ 1 file changed, 2 insertions(+)drivers/mtd/lpddr/lpddr2_nvm.c +0
-0@@ -433,6 +433,8 @@ static int lpddr2_nvm_probe(struct platform_device *pdev)
Quoted 5 lines
drivers/mtd/lpddr/lpddr2_nvm.c static int lpddr2_nvm_probe(struct platform_device *pdev) · line 436
Quoted 3 lines
drivers/mtd/lpddr/lpddr2_nvm.c +1
-0/* lpddr2_nvm address range */ add_range =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (IS_ERR (add_range))
platform_get_resource()just returns NULL upon error.
Thanks