Re: [PATCH v3] clk: starfive: jh7110: fix memory leak in jh7110_reset_controller_register() error path
From: Brian Masney
Date: Tue Apr 14 2026 - 16:06:41 EST
On Tue, Apr 14, 2026 at 07:44:18PM +0800, Guangshuo Li wrote:
> Hi Brian,
>
> Thanks for reviewing.
>
> On Tue, 14 Apr 2026 at 00:46, Brian Masney <bmasney@xxxxxxxxxx> wrote:
>
> > There's actually another leak in the error path for
> > auxiliary_device_add(). 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@xxxxxxxxxxxxxxxxxxxxxxxxxx/
> >
> > 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);
> return ret;
> }
>
> The embedded auxiliary_device has:
>
> adev->dev.release = jh7110_reset_adev_release;
>
> and the release callback does:
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