* [PATCH] spi: mtk-snfi: fix memory leak in probe
@ 2026-04-16 11:46 Felix Gu
2026-04-16 12:51 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Felix Gu @ 2026-04-16 11:46 UTC (permalink / raw)
To: Mark Brown, Matthias Brugger, AngeloGioacchino Del Regno,
Xiangsheng Hou
Cc: linux-spi, linux-kernel, linux-arm-kernel, linux-mediatek,
Felix Gu
ms->buf is allocated in mtk_snand_setup_pagefmt() but was not freed on
the following error paths.
Fixes: 2b1e19811a8e ("spi: mtk-snfi: Change default page format to setup default setting")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
drivers/spi/spi-mtk-snfi.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-mtk-snfi.c b/drivers/spi/spi-mtk-snfi.c
index 73fa84475f0e..a728cf571b78 100644
--- a/drivers/spi/spi-mtk-snfi.c
+++ b/drivers/spi/spi-mtk-snfi.c
@@ -1447,14 +1447,14 @@ static int mtk_snand_probe(struct platform_device *pdev)
ret = nand_ecc_register_on_host_hw_engine(&ms->ecc_eng);
if (ret) {
dev_err(&pdev->dev, "failed to register ecc engine.\n");
- goto release_ecc;
+ goto free_buf;
}
ret = devm_add_action_or_reset(&pdev->dev, mtk_unregister_ecc_engine,
&ms->ecc_eng);
if (ret) {
dev_err_probe(&pdev->dev, ret, "failed to add ECC unregister action\n");
- goto release_ecc;
+ goto free_buf;
}
ctlr->num_chipselect = 1;
@@ -1469,6 +1469,8 @@ static int mtk_snand_probe(struct platform_device *pdev)
}
return 0;
+free_buf:
+ kfree(ms->buf);
release_ecc:
mtk_ecc_release(ms->ecc);
return ret;
---
base-commit: 936c21068d7ade00325e40d82bfd2f3f29d9f659
change-id: 20260415-mtk-snfi-651a984002ba
Best regards,
--
Felix Gu <ustc.gu@gmail.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] spi: mtk-snfi: fix memory leak in probe
2026-04-16 11:46 [PATCH] spi: mtk-snfi: fix memory leak in probe Felix Gu
@ 2026-04-16 12:51 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2026-04-16 12:51 UTC (permalink / raw)
To: Felix Gu
Cc: Matthias Brugger, AngeloGioacchino Del Regno, Xiangsheng Hou,
linux-spi, linux-kernel, linux-arm-kernel, linux-mediatek
[-- Attachment #1: Type: text/plain, Size: 703 bytes --]
On Thu, Apr 16, 2026 at 07:46:20PM +0800, Felix Gu wrote:
> ms->buf is allocated in mtk_snand_setup_pagefmt() but was not freed on
> the following error paths.
> ret = nand_ecc_register_on_host_hw_engine(&ms->ecc_eng);
> if (ret) {
> dev_err(&pdev->dev, "failed to register ecc engine.\n");
> - goto release_ecc;
> + goto free_buf;
> }
>
> ret = devm_add_action_or_reset(&pdev->dev, mtk_unregister_ecc_engine,
> &ms->ecc_eng);
> if (ret) {
> dev_err_probe(&pdev->dev, ret, "failed to add ECC unregister action\n");
> - goto release_ecc;
> + goto free_buf;
> }
>
> ctlr->num_chipselect = 1;
What about spi_register_controller() failures?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-16 12:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-16 11:46 [PATCH] spi: mtk-snfi: fix memory leak in probe Felix Gu
2026-04-16 12:51 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox