Re: [PATCH v2 1/8] cpufreq: tegra186: add OPP support and set bandwidth

From: Aaron Kling

Date: Sun Oct 12 2025 - 22:32:47 EST


On Tue, Sep 30, 2025 at 5:30 AM Viresh Kumar <viresh.kumar@xxxxxxxxxx> wrote:
>
> On 09-09-25, 01:21, Aaron Kling via B4 Relay wrote:
> > +static int tegra_cpufreq_set_bw(struct cpufreq_policy *policy, unsigned long freq_khz)
> > +{
> > + struct tegra186_cpufreq_data *data = cpufreq_get_driver_data();
> > + struct dev_pm_opp *opp __free(put_opp);
>
> The usage here looks incorrect..
>
> > + struct device *dev;
> > + int ret;
> > +
> > + dev = get_cpu_device(policy->cpu);
> > + if (!dev)
> > + return -ENODEV;
>
> On failure, we would return from here with a garbage `opp` pointer, which the
> OPP core may try to free ?
>
> Moving the variable definition here would fix that.

If the var was NULL initialized, would the free handle that correctly?
Keeping the declarations at the start of the function reads better
imo.

Aaron