[PATCH] cpufreq: mediatek: fix device leak on probe failure

Johan Hovold johan at kernel.org
Tue Sep 9 03:03:54 PDT 2025


On Tue, Sep 09, 2025 at 05:57:45PM +0800, Chen-Yu Tsai wrote:
> On Tue, Sep 9, 2025 at 5:40 PM Johan Hovold <johan at kernel.org> wrote:
> >
> > Make sure to drop the reference to the cci device taken by
> > of_find_device_by_node() on probe failure (e.g. probe deferral).

> > @@ -552,6 +554,10 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
> >  out_free_mux_clock:
> >         clk_put(info->cpu_clk);
> >
> > +out_put_cci_dev:
> > +       if (info->soc_data->ccifreq_supported)
> > +               put_device(info->cci_dev);
> 
> put_device() has a check for NULL, so the if isn't really needed.

I know, but this follows the pattern currently used by the driver (e.g.
for regulator_put()) and avoids relying on the caller having cleared the
info struct.

> Either way,
> 
> Reviewed-by: Chen-Yu Tsai <wenst at chromium.org>

Thanks for reviewing.

Johan



More information about the Linux-mediatek mailing list