From: Weilin Tong <tongweilin@linux.alibaba.com>
To: Yazen Ghannam <yazen.ghannam@amd.com>
Cc: Borislav Petkov <bp@alien8.de>, Tony Luck <tony.luck@intel.com>,
linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Qinyun Tan <qinyuntan@linux.alibaba.com>
Subject: [PATCH] EDAC/amd64: Fix double free of private data on registration failure
Date: Wed, 21 Oct 2026 14:29:20 +0800 [thread overview]
Message-ID: <20261021062925.1838750-1-tongweilin@linux.alibaba.com> (raw)
If edac_mc_add_mc_with_groups() fails, init_one_instance() calls
edac_mc_free(), which frees mci->pvt_info. probe_one_instance() then
accesses and frees the same private data, causing a use-after-free
and a double free.
Clear mci->pvt_info before calling edac_mc_free() to leave the cleanup
to probe_one_instance(). The normal remove path already clears it.
Fixes: 0bbb265f7089 ("EDAC/mc: Get rid of silly one-shot struct allocation in edac_mc_alloc()")
Cc: stable@vger.kernel.org
Reported-by: Qinyun Tan <qinyuntan@linux.alibaba.com>
Signed-off-by: Weilin Tong <tongweilin@linux.alibaba.com>
---
drivers/edac/amd64_edac.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 0c0d11c72925..edced7cbe83f 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -3975,6 +3975,7 @@ static int init_one_instance(struct amd64_pvt *pvt)
ret = -ENODEV;
if (edac_mc_add_mc_with_groups(mci, amd64_edac_attr_groups)) {
edac_dbg(1, "failed edac_mc_add_mc()\n");
+ mci->pvt_info = NULL;
edac_mc_free(mci);
return ret;
}
base-commit: 2c455ddca7827ad8fa3a64fdbf5a60efb928b46a
--
2.43.5
next reply other threads:[~2026-10-21 6:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 6:29 Weilin Tong [this message]
2026-10-24 15:09 ` Yazen Ghannam
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=20261021062925.1838750-1-tongweilin@linux.alibaba.com \
--to=tongweilin@linux.alibaba.com \
--cc=bp@alien8.de \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=qinyuntan@linux.alibaba.com \
--cc=stable@vger.kernel.org \
--cc=tony.luck@intel.com \
--cc=yazen.ghannam@amd.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®