Skip to content

Commit

Permalink
mtd: maps: pxa2xx-flash: fix memory leak in probe
Browse files Browse the repository at this point in the history
[ Upstream commit 2399401 ]

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

Fixes: e644f7d ("[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>
  • Loading branch information
Zheng Yongjun authored and gregkh committed Dec 31, 2022
1 parent 616dc89 commit a1b061c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/mtd/maps/pxa2xx-flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,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);
Expand All @@ -85,6 +86,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;
Expand Down

0 comments on commit a1b061c

Please sign in to comment.