Re: [PATCH] cpufreq: apple-soc: Fix possible null-ptr-deref for cpufreq_cpu_get_raw()

From: Marc Zyngier
Date: Mon Dec 30 2024 - 04:31:03 EST


On Mon, 30 Dec 2024 03:57:14 +0000,
Charles Han <hanchunchao@xxxxxxxxxx> wrote:
>
> cpufreq_cpu_get_raw() may return NULL if the cpu is not in
> policy->cpus cpu mask and it will cause null pointer dereference.
> But this returned value in apple_soc_cpufreq_get_rate() is not
> checked. Add NULL check in apple_soc_cpufreq_get_rate(), to handle
> kernel NULL pointer dereference error.

The only way I can see a CPU not having an assigned policy is when the
DT is incomplete. And even then, reaching this code path doesn't look
obvious to me.

Can you describe how you get into this situation?

Thanks,

M.

--
Without deviation from the norm, progress is not possible.