From: Prasanna Kumar T S M Date: Sun, 22 Mar 2026 13:11:39 +0000 (-0700) Subject: EDAC/versalnet: Fix memory leak in remove and probe error paths X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1b6f292cb94d95c9bc22e1efe592daf62c60bc2e;p=thirdparty%2Fkernel%2Flinux.git EDAC/versalnet: Fix memory leak in remove and probe error paths 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 a memory leak. Fix it by freeing the allocated memory. Fixes: d5fe2fec6c40d ("EDAC: Add a driver for the AMD Versal NET DDR controller") Signed-off-by: Prasanna Kumar T S M Signed-off-by: Borislav Petkov (AMD) Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20260322131139.1684716-1-ptsm@linux.microsoft.com --- diff --git a/drivers/edac/versalnet_edac.c b/drivers/edac/versalnet_edac.c index 0b47ed7fed638..b87fe57aa8425 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); @@ -958,6 +959,7 @@ static void mc_remove(struct platform_device *pdev) remove_versalnet(priv); rproc_shutdown(priv->mcdi->r5_rproc); cdx_mcdi_finish(priv->mcdi); + kfree(priv->mcdi); } static const struct of_device_id amd_edac_match[] = {