diff options
| author | Hui Tang <[email protected]> | 2022-11-14 09:02:40 +0000 |
|---|---|---|
| committer | Miquel Raynal <[email protected]> | 2022-11-17 20:59:03 +0000 |
| commit | 6bdd45d795adf9e73b38ced5e7f750cd199499ff (patch) | |
| tree | fa2d00ddba48c063b56939d852bd4ccc629f747a /drivers/mtd/lpddr/lpddr2_nvm.c | |
| parent | dt-bindings: mtd: partitions: allow SafeLoader dynamic subpartitions (diff) | |
| download | kernel-6bdd45d795adf9e73b38ced5e7f750cd199499ff.tar.gz kernel-6bdd45d795adf9e73b38ced5e7f750cd199499ff.zip | |
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")
Signed-off-by: Hui Tang <[email protected]>
Acked-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Miquel Raynal <[email protected]>
Link: https://lore.kernel.org/linux-mtd/[email protected]
Diffstat (limited to 'drivers/mtd/lpddr/lpddr2_nvm.c')
| -rw-r--r-- | drivers/mtd/lpddr/lpddr2_nvm.c | 2 |
1 files changed, 2 insertions, 0 deletions
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) { |
