summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>2021-05-27 11:43:22 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-07-20 16:21:15 +0200
commit3b45b8a7d549bd92ec94b5357c2c2c1a7ed107e4 (patch)
treec1a5de841b9df57edd9f3fc6d2f1bf32a916ac17
parentd0d04b95e8ed0223844a1d58497c686fe2e4a955 (diff)
downloadlinux-stable-3b45b8a7d549bd92ec94b5357c2c2c1a7ed107e4.tar.gz
linux-stable-3b45b8a7d549bd92ec94b5357c2c2c1a7ed107e4.tar.bz2
linux-stable-3b45b8a7d549bd92ec94b5357c2c2c1a7ed107e4.zip
memory: fsl_ifc: fix leak of private memory on probe failure
[ Upstream commit 8e0d09b1232d0538066c40ed4c13086faccbdff6 ] On probe error the driver should free the memory allocated for private structure. Fix this by using resource-managed allocation. Fixes: a20cbdeffce2 ("powerpc/fsl: Add support for Integrated Flash Controller") Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Link: https://lore.kernel.org/r/20210527154322.81253-2-krzysztof.kozlowski@canonical.com Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/memory/fsl_ifc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c
index 74bbbdc584f4..38b945eb410f 100644
--- a/drivers/memory/fsl_ifc.c
+++ b/drivers/memory/fsl_ifc.c
@@ -109,7 +109,6 @@ static int fsl_ifc_ctrl_remove(struct platform_device *dev)
iounmap(ctrl->gregs);
dev_set_drvdata(&dev->dev, NULL);
- kfree(ctrl);
return 0;
}
@@ -221,7 +220,8 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev)
dev_info(&dev->dev, "Freescale Integrated Flash Controller\n");
- fsl_ifc_ctrl_dev = kzalloc(sizeof(*fsl_ifc_ctrl_dev), GFP_KERNEL);
+ fsl_ifc_ctrl_dev = devm_kzalloc(&dev->dev, sizeof(*fsl_ifc_ctrl_dev),
+ GFP_KERNEL);
if (!fsl_ifc_ctrl_dev)
return -ENOMEM;