[PATCH 3/5] EDAC/versalnet: Fix memory leak in remove and probe error paths
From: Prasanna Kumar T S M
Date: Sun Mar 22 2026 - 09:11:53 EST
The mcdi object allocated using kzalloc() in the setup_mcdi() is not
freed in the remove path or in probe's error handling path leading to
memory leak. Fix the memory leak by freeing the allocated memory.
Fixes: d5fe2fec6c40d ("EDAC: Add a driver for the AMD Versal NET DDR controller")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Prasanna Kumar T S M <ptsm@xxxxxxxxxxxxxxxxxxx>
---
drivers/edac/versalnet_edac.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/edac/versalnet_edac.c b/drivers/edac/versalnet_edac.c
index 28f5036f381c..acd51b492772 100644
--- a/drivers/edac/versalnet_edac.c
+++ b/drivers/edac/versalnet_edac.c
@@ -937,6 +937,7 @@ static int mc_probe(struct platform_device *pdev)
err_init:
cdx_mcdi_finish(priv->mcdi);
+ kfree(priv->mcdi);
err_unreg:
unregister_rpmsg_driver(&amd_rpmsg_driver);
@@ -959,6 +960,7 @@ static void mc_remove(struct platform_device *pdev)
unregister_rpmsg_driver(&amd_rpmsg_driver);
rproc_shutdown(priv->mcdi->r5_rproc);
rproc_put(priv->mcdi->r5_rproc);
+ kfree(priv->mcdi);
}
static const struct of_device_id amd_edac_match[] = {
--
2.49.0