From: Brian Masney <bmasney@redhat.com>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: "Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>,
"Gregory CLEMENT" <gregory.clement@bootlin.com>,
"Théo Lebrun" <theo.lebrun@bootlin.com>,
"Michael Turquette" <mturquette@baylibre.com>,
"Stephen Boyd" <sboyd@kernel.org>,
linux-mips@vger.kernel.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] clk: eyeq: fix memory leak in eqc_auxdev_create() error path
Date: Tue, 14 Apr 2026 16:06:03 -0400 [thread overview]
Message-ID: <ad6eK7wQF8M6sRLG@redhat.com> (raw)
In-Reply-To: <CANUHTR-9HYnCuavM9O_wcVg3VuDyV4zQH4P9jYhViBj_PbYV9A@mail.gmail.com>
On Tue, Apr 14, 2026 at 07:49:31PM +0800, Guangshuo Li wrote:
> Hi Brian,
>
> Thanks for reviewing.
>
> On Tue, 14 Apr 2026 at 00:42, Brian Masney <bmasney@redhat.com> wrote:
> >
> > There is a leak in the error path here as well. I think this code
> > should be converted to devm_kzalloc().
> >
> > There is no devm_kzalloc_obj() yet, however according to [1] that should
> > be coming soon.
> >
> > [1] https://lore.kernel.org/lkml/20260330154108.GA3389518@killaraus.ideasonboard.com/
> >
> > Brian
> >
>
> I may be missing something, but I think the auxiliary_device_add() error
> path is already handled here:
>
> ret = auxiliary_device_add(adev);
> if (ret)
> auxiliary_device_uninit(adev);
>
> The auxiliary device also has:
>
> adev->dev.release = eqc_auxdev_release;
>
> with:
>
> static void eqc_auxdev_release(struct device *dev)
> {
> struct auxiliary_device *adev = to_auxiliary_dev(dev);
>
> kfree(adev);
> }
>
> So my understanding was that after a successful auxiliary_device_init(),
> the auxiliary_device_add() failure path should be cleaned up through
> auxiliary_device_uninit(), which would eventually invoke the release
> callback and free adev.
>
> The leak I was trying to fix is only the auxiliary_device_init() failure
> path, where the function returns directly before that cleanup path is
> available.
>
> Please let me know if I overlooked something.
You are right. Sorry about that. My original suggestion still applies
though to move over to the devm variant since that'll allow you to
remove the release callback.
Brian
prev parent reply other threads:[~2026-04-14 20:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-12 12:42 [PATCH v2] clk: eyeq: fix memory leak in eqc_auxdev_create() error path Guangshuo Li
2026-04-13 8:04 ` Théo Lebrun
2026-04-14 11:51 ` Guangshuo Li
2026-04-13 16:42 ` Brian Masney
2026-04-14 11:49 ` Guangshuo Li
2026-04-14 20:06 ` Brian Masney [this message]
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=ad6eK7wQF8M6sRLG@redhat.com \
--to=bmasney@redhat.com \
--cc=gregory.clement@bootlin.com \
--cc=lgs201920130244@gmail.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
--cc=stable@vger.kernel.org \
--cc=theo.lebrun@bootlin.com \
--cc=vladimir.kondratiev@mobileye.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