Skip to content

Commit

Permalink
memory: fsl_ifc: fix leak of private memory on probe failure
Browse files Browse the repository at this point in the history
[ Upstream commit 8e0d09b ]

On probe error the driver should free the memory allocated for private
structure.  Fix this by using resource-managed allocation.

Fixes: a20cbde ("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>
  • Loading branch information
krzk authored and gregkh committed Jul 20, 2021
1 parent 28f71fd commit a6b45b4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/memory/fsl_ifc.c
Expand Up @@ -97,7 +97,6 @@ static int fsl_ifc_ctrl_remove(struct platform_device *dev)
iounmap(ctrl->gregs);

dev_set_drvdata(&dev->dev, NULL);
kfree(ctrl);

return 0;
}
Expand Down Expand Up @@ -209,7 +208,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;

Expand Down

0 comments on commit a6b45b4

Please sign in to comment.