From: "Pandey, Radhey Shyam" <radheys@amd.com>
To: Tarun Sahu <tarunsahu@google.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Geoff Levand <geoff@infradead.org>,
"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
Nicholas Piggin <npiggin@gmail.com>,
Michael Ellerman <mpe@ellerman.id.au>,
dmatlack@google.com, Borislav Petkov <bp@alien8.de>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>,
djeffery@redhat.com, Tony Luck <tony.luck@intel.com>,
skhawaja@google.com, Russell King <linux@armlinux.org.uk>,
stuart.w.hayes@gmail.com
Cc: linuxppc-dev@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, driver-core@lists.linux.dev,
linux-edac@vger.kernel.org
Subject: Re: [PATCH 3/4] EDAC/versalnet: use put_device() on device_register() failure
Date: Tue, 11 Aug 2026 12:14:34 +0530 [thread overview]
Message-ID: <9e189214-1274-491b-97dc-1b943c6c5cea@amd.com> (raw)
In-Reply-To: <20260810162814.1398016-4-tarunsahu@google.com>
On 8/10/2026 9:58 PM, Tarun Sahu wrote:
> When device_register() fails, calling kfree(dev) directly bypasses the
> device_release() callback (versal_edac_release) and leaks the allocated
> driver core structures.
>
> Fix this by calling put_device(dev) when device_register() returns an
> error, ensuring proper refcount decrement and release cleanup.
>
> Signed-off-by: Tarun Sahu <tarunsahu@google.com>
Thanks for the patch. FYI, this issue is already being addressed in an
ongoing series.
https://lore.kernel.org/all/20260724171945.2812749-5-shubhrajyoti.datta@amd.com/
-Radhey
> ---
> drivers/edac/versalnet_edac.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/edac/versalnet_edac.c b/drivers/edac/versalnet_edac.c
> index 97ec05d68bbb..2912b3658915 100644
> --- a/drivers/edac/versalnet_edac.c
> +++ b/drivers/edac/versalnet_edac.c
> @@ -829,8 +829,10 @@ static int init_one_mc(struct mc_priv *priv, struct platform_device *pdev, int i
> dev->release = versal_edac_release;
>
> rc = device_register(dev);
> - if (rc)
> + if (rc) {
> + put_device(dev);
> goto err_mc_free;
> + }
>
> mci->pdev = dev;
> mc_init(mci, dev);
> @@ -852,9 +854,9 @@ static int init_one_mc(struct mc_priv *priv, struct platform_device *pdev, int i
> device_unregister(mci->pdev);
> err_mc_free:
> edac_mc_free(mci);
> + return rc;
> err_dev_free:
> kfree(dev);
> -
> return rc;
> }
>
next prev parent reply other threads:[~2026-08-11 14:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 16:28 [PATCH 0/4] Convert manual kfree(dev) to put_device() Tarun Sahu
2026-08-10 16:28 ` [PATCH 1/4] ARM: locomo: use put_device() on device_register() failure Tarun Sahu
2026-08-10 16:28 ` [PATCH 2/4] firmware/edd: use kobject_put() on edd_device_register() failure Tarun Sahu
2026-08-10 16:28 ` [PATCH 3/4] EDAC/versalnet: use put_device() on device_register() failure Tarun Sahu
2026-08-11 6:44 ` Pandey, Radhey Shyam [this message]
2026-08-11 10:39 ` tarunsahu
2026-08-10 16:28 ` [PATCH 4/4] powerpc/ps3: use put_device() on device_register() failure in ps3_system_bus_device_register Tarun Sahu
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=9e189214-1274-491b-97dc-1b943c6c5cea@amd.com \
--to=radheys@amd.com \
--cc=bp@alien8.de \
--cc=chleroy@kernel.org \
--cc=djeffery@redhat.com \
--cc=dmatlack@google.com \
--cc=driver-core@lists.linux.dev \
--cc=geoff@infradead.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=shubhrajyoti.datta@amd.com \
--cc=skhawaja@google.com \
--cc=stuart.w.hayes@gmail.com \
--cc=tarunsahu@google.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