From: Sourabh Jain <sourabhjain@linux.ibm.com>
To: Tarun Sahu <tarunsahu@google.com>,
"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Russell King <linux@armlinux.org.uk>,
Geoff Levand <geoff@infradead.org>,
Michael Ellerman <mpe@ellerman.id.au>,
djeffery@redhat.com, Nicholas Piggin <npiggin@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-arm-kernel@lists.infradead.org, dmatlack@google.com,
Pasha Tatashin <pasha.tatashin@soleen.com>,
souravsgl@google.com, skhawaja@google.com,
linux-kernel@vger.kernel.org, driver-core@lists.linux.dev,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2 2/3] firmware/edd: use kobject_put() on edd_device_register() failure
Date: Fri, 14 Aug 2026 13:42:14 +0530 [thread overview]
Message-ID: <ce787895-e2f1-4e32-b2c7-737e26c862f9@linux.ibm.com> (raw)
In-Reply-To: <20260813095421.1700945-3-tarunsahu@google.com>
On 13/08/26 15:24, Tarun Sahu wrote:
> When edd_device_register() fails after initializing the kobject with
> kobject_init_and_add(), calling kfree(edev) directly bypasses the
> kobject release callback (edd_release) and leaks the allocated kobject
> resources.
>
> Fix this by replacing direct kfree(edev) with kobject_put(&edev->kobj) on
> registration failure.
>
> Signed-off-by: Tarun Sahu <tarunsahu@google.com>
> ---
> drivers/firmware/edd.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c
> index f980c5b56858..763e7b16d517 100644
> --- a/drivers/firmware/edd.c
> +++ b/drivers/firmware/edd.c
> @@ -748,7 +748,7 @@ edd_init(void)
>
> rc = edd_device_register(edev, i);
> if (rc) {
> - kfree(edev);
> + kobject_put(&edev->kobj);
The EDD device is registered with a ktype that has a release function,
so it is
better to call kobject_put() to release edev instead of freeing the
memory manually.
Changes look good to me. Feel free to add:
Reviewed-by: Sourabh Jain <sourabhjain@linux.ibm.com>
> goto out;
> }
> edd_devices[i] = edev;
next prev parent reply other threads:[~2026-08-14 8:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 9:54 [PATCH v2 0/3] Convert manual kfree(dev) to put_device() Tarun Sahu
2026-08-13 9:54 ` [PATCH v2 1/3] ARM: locomo: use put_device() on device_register() failure Tarun Sahu
2026-08-14 7:08 ` Sourabh Jain
2026-08-13 9:54 ` [PATCH v2 2/3] firmware/edd: use kobject_put() on edd_device_register() failure Tarun Sahu
2026-08-14 8:12 ` Sourabh Jain [this message]
2026-08-13 9:54 ` [PATCH v2 3/3] powerpc/ps3: use put_device() on device_register() failure in ps3_system_bus_device_register Tarun Sahu
2026-08-14 2:30 ` Sourabh Jain
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=ce787895-e2f1-4e32-b2c7-737e26c862f9@linux.ibm.com \
--to=sourabhjain@linux.ibm.com \
--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-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=pasha.tatashin@soleen.com \
--cc=skhawaja@google.com \
--cc=souravsgl@google.com \
--cc=tarunsahu@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.