]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mtd: maps: pxa2xx-flash: fix memory leak in probe
authorZheng Yongjun <zhengyongjun3@huawei.com>
Sat, 19 Nov 2022 07:33:07 +0000 (07:33 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:05 +0000 (11:41 +0100)
[ Upstream commit 2399401feee27c639addc5b7e6ba519d3ca341bf ]

Free 'info' upon remapping error to avoid a memory leak.

Fixes: 1c573b89da05 ("[MTD] MAPS: Merge Lubbock and Mainstone drivers into common PXA2xx driver")
Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
[<miquel.raynal@bootlin.com>: Reword the commit log]
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20221119073307.22929-1-zhengyongjun3@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mtd/maps/pxa2xx-flash.c

index 7d96758a8f04e0cf2a8b0da4eec31e8cab363e23..6e5e557559704d2393ae6ddf895d682c09083183 100644 (file)
@@ -66,6 +66,7 @@ static int pxa2xx_flash_probe(struct platform_device *pdev)
        if (!info->map.virt) {
                printk(KERN_WARNING "Failed to ioremap %s\n",
                       info->map.name);
+               kfree(info);
                return -ENOMEM;
        }
        info->map.cached = ioremap_cache(info->map.phys, info->map.size);
@@ -87,6 +88,7 @@ static int pxa2xx_flash_probe(struct platform_device *pdev)
                iounmap((void *)info->map.virt);
                if (info->map.cached)
                        iounmap(info->map.cached);
+               kfree(info);
                return -EIO;
        }
        info->mtd->dev.parent = &pdev->dev;