From: Prasanna Kumar T S M <ptsm@linux.microsoft.com>
To: ptsm@linux.microsoft.com, shubhrajyoti.datta@amd.com,
bp@alien8.de, tony.luck@intel.com, linux-edac@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 5/5] EDAC/versalnet: Fix device name memory leak
Date: Sun, 22 Mar 2026 06:11:49 -0700 [thread overview]
Message-ID: <20260322131149.1684771-1-ptsm@linux.microsoft.com> (raw)
In-Reply-To: <20260322131107.1684647-1-ptsm@linux.microsoft.com>
The device name allocated via kzalloc() in init_one_mc() is assigned to
dev->init_name but never freed on the normal removal path.
device_register() copies init_name and then sets dev->init_name to NULL,
so the name pointer becomes unreachable from the device. Thus leaking
memory.
Track the name pointer in mc_priv and free it in remove_one_mc().
Fixes: d5fe2fec6c40d ("EDAC: Add a driver for the AMD Versal NET DDR controller")
Cc: stable@vger.kernel.org
Signed-off-by: Prasanna Kumar T S M <ptsm@linux.microsoft.com>
---
drivers/edac/versalnet_edac.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/edac/versalnet_edac.c b/drivers/edac/versalnet_edac.c
index 6463e88ed3d3..17a5c8f416b9 100644
--- a/drivers/edac/versalnet_edac.c
+++ b/drivers/edac/versalnet_edac.c
@@ -158,6 +158,7 @@ struct mc_priv {
u32 regs[REG_MAX];
u32 adec[ADEC_MAX];
struct mem_ctl_info *mci[NUM_CONTROLLERS];
+ char *mci_name[NUM_CONTROLLERS];
struct rpmsg_endpoint *ept;
struct cdx_mcdi *mcdi;
};
@@ -765,11 +766,14 @@ static void versal_edac_release(struct device *dev)
static void remove_one_mc(struct mc_priv *priv, int i)
{
struct mem_ctl_info *mci;
+ char *mci_name;
mci = priv->mci[i];
device_unregister(mci->pdev);
edac_mc_del_mc(mci->pdev);
edac_mc_free(mci);
+ mci_name = priv->mci_name[i];
+ kfree(mci_name);
}
static int init_one_mc(struct mc_priv *priv, struct platform_device *pdev, int i)
@@ -848,6 +852,7 @@ static int init_one_mc(struct mc_priv *priv, struct platform_device *pdev, int i
}
priv->mci[i] = mci;
+ priv->mci_name[i] = name;
priv->dwidth = dt;
platform_set_drvdata(pdev, priv);
--
2.49.0
next prev parent reply other threads:[~2026-03-22 13:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-22 13:11 [PATCH 1/5] EDAC/versalnet: Fix teardown ordering in mc_remove() Prasanna Kumar T S M
2026-03-22 13:11 ` [PATCH 2/5] EDAC/versalnet: Release reference to remoteproc device in remove Prasanna Kumar T S M
2026-03-22 15:59 ` Borislav Petkov
2026-03-23 7:25 ` Prasanna Kumar T S M
2026-03-22 13:11 ` [PATCH 3/5] EDAC/versalnet: Fix memory leak in remove and probe error paths Prasanna Kumar T S M
2026-03-22 19:15 ` Borislav Petkov
2026-03-22 13:11 ` [PATCH 4/5] EDAC/versalnet: Fix device_register() error handling in init_one_mc() Prasanna Kumar T S M
2026-03-22 16:10 ` Borislav Petkov
2026-03-23 7:08 ` Prasanna Kumar T S M
2026-03-24 11:23 ` Borislav Petkov
2026-03-24 12:16 ` Borislav Petkov
2026-03-22 13:11 ` Prasanna Kumar T S M [this message]
2026-03-22 16:15 ` [PATCH 5/5] EDAC/versalnet: Fix device name memory leak Borislav Petkov
2026-03-23 6:59 ` Prasanna Kumar T S M
2026-03-26 17:23 ` kernel test robot
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=20260322131149.1684771-1-ptsm@linux.microsoft.com \
--to=ptsm@linux.microsoft.com \
--cc=bp@alien8.de \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shubhrajyoti.datta@amd.com \
--cc=stable@vger.kernel.org \
--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