Re: [PATCH] cpufreq: imx6q: fix devres accumulation across driver rebind

Viresh Kumar <[email protected]>
Newsgroups dev.linux.lists.imx,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pm
Message-ID <xale3cobuizjnufkp2fkvxmq66dl2cmuoh6szd4d4vhwfcxizp@4kp2zcpu2ndw>
On 06-08-26, 07:09, Karl Mehltretter wrote:
> imx6_soc_volt is allocated with devm_kcalloc(cpu_dev, ...), where cpu_dev
> is the CPU device from get_cpu_device(0). That device is never unbound, so
> its devres list is never released, and imx6q_cpufreq_remove() does not free
> the array either. Every probe therefore adds an allocation that stays for
> the lifetime of the system.
> 
> Allocate against the platform device instead. Its devres is released when
> the driver is unbound, which is exactly the lifetime the array wants:
> imx6q_set_target() reads it, and nothing may reach that after
> cpufreq_unregister_driver().
> 
> That makes the array actually go away on unbind, so also clear the
> file-scope pointer in remove and on the failed-probe path, rather than
> leave it pointing at memory devres is about to release.
> 
> Tested by rebinding the driver on qemu's mcimx6ul-evk.
> 
> Fixes: b4573d1d657a ("cpufreq: imx6q: correct VDDSOC/PU voltage scaling when cpufreq is changed")
> Assisted-by: Claude:claude-opus-5
> Signed-off-by: Karl Mehltretter <[email protected]>
> ---
>  drivers/cpufreq/imx6q-cpufreq.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Applied. Thanks.

-- 
viresh
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.