Re: [PATCH v2 1/3] EDAC/versalnet: Fix teardown ordering in mc_remove()
From: Prasanna Kumar T S M
Date: Thu Jul 09 2026 - 02:34:13 EST
Hi Shubrajyoti,
On 08-06-2026 16:41, Shubhrajyoti Datta wrote:
On Wed, Apr 1, 2026 at 4:56 PM Prasanna Kumar T S M
<ptsm@xxxxxxxxxxxxxxxxxxx> wrote:
The teardown sequence in mc_remove() does not mirror the reverse of the
initialization order in mc_probe(). In particular,
unregister_rpmsg_driver() is called before remove_versalnet(), and
cdx_mcdi_finish() is called after rproc_shutdown().
Reorder mc_remove() to reverse the probe initialization sequence,
consistent with the probe error-unwind paths.
I think that the remote proc should be quiescence first so that no
more messages will be
queued. and then the edac should be removed. See below.
The rproc reference acquired via rproc_get_by_phandle() during probe
is not released in mc_remove(), causing a reference count leak. Add
the missing rproc_put() call.
Fixes: d5fe2fec6c40 ("EDAC: Add a driver for the AMD Versal NET DDR controller")
Signed-off-by: Prasanna Kumar T S M <ptsm@xxxxxxxxxxxxxxxxxxx>
---
drivers/edac/versalnet_edac.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/edac/versalnet_edac.c b/drivers/edac/versalnet_edac.c
index b87fe57aa842..acd51b492772 100644
--- a/drivers/edac/versalnet_edac.c
+++ b/drivers/edac/versalnet_edac.c
@@ -955,10 +955,11 @@ static void mc_remove(struct platform_device *pdev)
{
struct mc_priv *priv = platform_get_drvdata(pdev);
- unregister_rpmsg_driver(&amd_rpmsg_driver);
remove_versalnet(priv);
Here we are removing the edac but the remoteproc can be triggered.
calling the remote callback.
Thanks for the review.
This suggests that my change is not complete. I am not sufficiently familiar with this area to provide a correct fix, so I will leave it to someone more knowledgeable.
- rproc_shutdown(priv->mcdi->r5_rproc);The put is a valid fix.
cdx_mcdi_finish(priv->mcdi);
+ unregister_rpmsg_driver(&amd_rpmsg_driver);
+ rproc_shutdown(priv->mcdi->r5_rproc);
+ rproc_put(priv->mcdi->r5_rproc);
kfree(priv->mcdi);
}
--
2.49.0
Thanks,
Prasanna