]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mtd: lpddr2_nvm: Fix possible null-ptr-deref
authorHui Tang <tanghui20@huawei.com>
Mon, 14 Nov 2022 09:02:40 +0000 (17:02 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:03 +0000 (11:41 +0100)
[ Upstream commit 6bdd45d795adf9e73b38ced5e7f750cd199499ff ]

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

Fixes: 83f663f4c04f ("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>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20221114090240.244172-1-tanghui20@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mtd/lpddr/lpddr2_nvm.c

index 72f5c7b300790f8d8d29d158f49f7cbb59a96e7f..add4386f99f0088479da4eafb0b5387783f4706a 100644 (file)
@@ -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) {