* [RFT PATCH v2 1/2] memory: fsl_ifc: fix leaking IO mapping on probe failure
@ 2021-05-27 15:43 Krzysztof Kozlowski
2021-05-27 15:43 ` [RFT PATCH v2 2/2] memory: fsl_ifc: fix leak of private memory " Krzysztof Kozlowski
2021-06-10 7:27 ` [RFT PATCH v2 1/2] memory: fsl_ifc: fix leaking IO mapping " Krzysztof Kozlowski
0 siblings, 2 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2021-05-27 15:43 UTC (permalink / raw)
To: Krzysztof Kozlowski, Liu Shuo, Prabhakar Kushwaha, Li Yang,
Dipen Dudhat, linux-kernel
Cc: Dan Carpenter, kernel test robot
On probe error the driver should unmap the IO memory. Smatch reports:
drivers/memory/fsl_ifc.c:298 fsl_ifc_ctrl_probe() warn: 'fsl_ifc_ctrl_dev->gregs' not released on lines: 298.
Fixes: a20cbdeffce2 ("powerpc/fsl: Add support for Integrated Flash Controller")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
Only build tested.
Changes since v1:
1. None
---
drivers/memory/fsl_ifc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c
index 89f99b5b6450..a6324044a085 100644
--- a/drivers/memory/fsl_ifc.c
+++ b/drivers/memory/fsl_ifc.c
@@ -219,8 +219,7 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev)
fsl_ifc_ctrl_dev->gregs = of_iomap(dev->dev.of_node, 0);
if (!fsl_ifc_ctrl_dev->gregs) {
dev_err(&dev->dev, "failed to get memory region\n");
- ret = -ENODEV;
- goto err;
+ return -ENODEV;
}
if (of_property_read_bool(dev->dev.of_node, "little-endian")) {
@@ -295,6 +294,7 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev)
free_irq(fsl_ifc_ctrl_dev->irq, fsl_ifc_ctrl_dev);
irq_dispose_mapping(fsl_ifc_ctrl_dev->irq);
err:
+ iounmap(fsl_ifc_ctrl_dev->gregs);
return ret;
}
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [RFT PATCH v2 2/2] memory: fsl_ifc: fix leak of private memory on probe failure
2021-05-27 15:43 [RFT PATCH v2 1/2] memory: fsl_ifc: fix leaking IO mapping on probe failure Krzysztof Kozlowski
@ 2021-05-27 15:43 ` Krzysztof Kozlowski
2021-06-10 7:27 ` [RFT PATCH v2 1/2] memory: fsl_ifc: fix leaking IO mapping " Krzysztof Kozlowski
1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2021-05-27 15:43 UTC (permalink / raw)
To: Krzysztof Kozlowski, Liu Shuo, Prabhakar Kushwaha, Li Yang,
Dipen Dudhat, linux-kernel
Cc: Dan Carpenter
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>
---
Only build tested.
Changes since v1:
1. kfree() in remove() as pointed out by Dan.
---
drivers/memory/fsl_ifc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c
index a6324044a085..d062c2f8250f 100644
--- a/drivers/memory/fsl_ifc.c
+++ b/drivers/memory/fsl_ifc.c
@@ -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;
}
@@ -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;
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFT PATCH v2 1/2] memory: fsl_ifc: fix leaking IO mapping on probe failure
2021-05-27 15:43 [RFT PATCH v2 1/2] memory: fsl_ifc: fix leaking IO mapping on probe failure Krzysztof Kozlowski
2021-05-27 15:43 ` [RFT PATCH v2 2/2] memory: fsl_ifc: fix leak of private memory " Krzysztof Kozlowski
@ 2021-06-10 7:27 ` Krzysztof Kozlowski
1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2021-06-10 7:27 UTC (permalink / raw)
To: Krzysztof Kozlowski, Li Yang, Dipen Dudhat, Prabhakar Kushwaha,
linux-kernel, Liu Shuo
Cc: Dan Carpenter, kernel test robot
On Thu, 27 May 2021 11:43:21 -0400, Krzysztof Kozlowski wrote:
> On probe error the driver should unmap the IO memory. Smatch reports:
>
> drivers/memory/fsl_ifc.c:298 fsl_ifc_ctrl_probe() warn: 'fsl_ifc_ctrl_dev->gregs' not released on lines: 298.
Applied, thanks!
[1/2] memory: fsl_ifc: fix leaking IO mapping on probe failure
commit: 3b132ab67fc7a358fff35e808fa65d4bea452521
[2/2] memory: fsl_ifc: fix leak of private memory on probe failure
commit: 8e0d09b1232d0538066c40ed4c13086faccbdff6
Best regards,
--
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-06-10 7:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27 15:43 [RFT PATCH v2 1/2] memory: fsl_ifc: fix leaking IO mapping on probe failure Krzysztof Kozlowski
2021-05-27 15:43 ` [RFT PATCH v2 2/2] memory: fsl_ifc: fix leak of private memory " Krzysztof Kozlowski
2021-06-10 7:27 ` [RFT PATCH v2 1/2] memory: fsl_ifc: fix leaking IO mapping " Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).