From: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
To: <linux-kernel@vger.kernel.org>, <linux-edac@vger.kernel.org>
Cc: <git@amd.com>, <shubhrajyoti.datta@gmail.com>,
Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>,
Borislav Petkov <bp@alien8.de>, Tony Luck <tony.luck@intel.com>,
Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>,
Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
Subject: [PATCH v3 4/7] EDAC/versalnet: Guard against NULL drvdata in rpmsg_cb()
Date: Fri, 27 Nov 2026 21:59:13 +0530 [thread overview]
Message-ID: <20261127163853.3563991-5-shubhrajyoti.datta@amd.com> (raw)
In-Reply-To: <20261127163853.3563991-1-shubhrajyoti.datta@amd.com>
The rpmsg core creates its own endpoint bound to rpmsg_cb() in
rpmsg_dev_probe(), before rpmsg_probe() runs and attaches mc_priv via
dev_set_drvdata(). A message dispatched to that endpoint in that
window would dereference a NULL mc_priv and crash.
The same race exists on the teardown side: rpmsg_dev_remove() calls
rpmsg_remove() first, which clears drvdata back to NULL, and only
destroys the core's default endpoint afterwards. A message arriving
in that window reaches rpmsg_cb() with drvdata already NULL.
Check for a NULL mc_priv in rpmsg_cb() and drop the message instead
of crashing, in either window.
Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Fixes: d5fe2fec6c40 ("EDAC: Add a driver for the AMD Versal NET DDR controller")
Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
---
Changes in v3:
Add reviewed by tag
Changes in v2:
Patch addition for the rpmsg drvdata race
drivers/edac/versalnet_edac.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/edac/versalnet_edac.c b/drivers/edac/versalnet_edac.c
index c43104a5d9f0..8c3f8733c049 100644
--- a/drivers/edac/versalnet_edac.c
+++ b/drivers/edac/versalnet_edac.c
@@ -631,6 +631,12 @@ static int rpmsg_cb(struct rpmsg_device *rpdev, void *data,
const char *err_str;
u32 *adec_data;
+ if (!mc_priv) {
+ dev_warn_ratelimited(&rpdev->dev,
+ "Dropping rpmsg message, driver not ready or being removed\n");
+ return 0;
+ }
+
if (*(u8 *)data == MCDI_RESPONSE) {
cdx_mcdi_process_cmd(mc_priv->mcdi, (struct cdx_dword *)data, len);
return 0;
--
2.34.1
next prev parent reply other threads:[~2026-11-27 16:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 16:29 [PATCH v3 0/7] EDAC/versalnet: Fix error handling, teardown, and robustness Shubhrajyoti Datta
2026-11-27 16:29 ` [PATCH v3 1/7] EDAC/versalnet: Add bounds validation in rpmsg_cb() Shubhrajyoti Datta
2026-11-27 16:29 ` [PATCH v3 2/7] EDAC/versalnet: Make dwidth per-controller Shubhrajyoti Datta
2026-11-27 16:29 ` [PATCH v3 3/7] EDAC/versalnet: Wait for RPMsg endpoint initialization Shubhrajyoti Datta
2026-11-27 16:51 ` Shubhrajyoti Datta
2026-11-27 16:29 ` Shubhrajyoti Datta [this message]
2026-11-27 16:29 ` [PATCH v3 5/7] EDAC/versalnet: Make get_ddr_config() return errors Shubhrajyoti Datta
2026-11-27 16:29 ` [PATCH v3 6/7] EDAC/versalnet: fix the remove controller crash Shubhrajyoti Datta
2026-11-27 16:29 ` [PATCH v3 7/7] EDAC/versalnet: Move platform_set_drvdata() to mc_probe() Shubhrajyoti Datta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127163853.3563991-5-shubhrajyoti.datta@amd.com \
--to=shubhrajyoti.datta@amd.com \
--cc=bp@alien8.de \
--cc=git@amd.com \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=radhey.shyam.pandey@amd.com \
--cc=sai.krishna.potthuri@amd.com \
--cc=shubhrajyoti.datta@gmail.com \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®