linux/drivers/cpufreq
Sudeep Holla 6941051d30 cpufreq: Cancel policy update work scheduled before freeing
Scheduled policy update work may end up racing with the freeing of the
policy and unregistering the driver.

One possible race is as below, where the cpufreq_driver is unregistered,
but the scheduled work gets executed at later stage when, cpufreq_driver
is NULL (i.e. after freeing the policy and driver).

Unable to handle kernel NULL pointer dereference at virtual address 0000001c
pgd = (ptrval)
[0000001c] *pgd=80000080204003, *pmd=00000000
Internal error: Oops: 206 [#1] SMP THUMB2
Modules linked in:
CPU: 0 PID: 34 Comm: kworker/0:1 Not tainted 5.4.0-rc3-00006-g67f5a8081a4b #86
Hardware name: ARM-Versatile Express
Workqueue: events handle_update
PC is at cpufreq_set_policy+0x58/0x228
LR is at dev_pm_qos_read_value+0x77/0xac
Control: 70c5387d  Table: 80203000  DAC: fffffffd
Process kworker/0:1 (pid: 34, stack limit = 0x(ptrval))
	(cpufreq_set_policy) from (refresh_frequency_limits.part.24+0x37/0x48)
	(refresh_frequency_limits.part.24) from (handle_update+0x2f/0x38)
	(handle_update) from (process_one_work+0x16d/0x3cc)
	(process_one_work) from (worker_thread+0xff/0x414)
	(worker_thread) from (kthread+0xff/0x100)
	(kthread) from (ret_from_fork+0x11/0x28)

Fixes: 67d874c3b2 ("cpufreq: Register notifiers with the PM QoS framework")
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
[ rjw: Cancel the work before dropping the QoS requests ]
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-10-22 18:07:30 +02:00
..
acpi-cpufreq.c
amd_freq_sensitivity.c
arm_big_little.c
arm_big_little.h
armada-8k-cpufreq.c
armada-37xx-cpufreq.c
bmips-cpufreq.c
brcmstb-avs-cpufreq.c
cppc_cpufreq.c
cpufreq_conservative.c
cpufreq_governor_attr_set.c
cpufreq_governor.c
cpufreq_governor.h
cpufreq_ondemand.c
cpufreq_ondemand.h
cpufreq_performance.c
cpufreq_powersave.c
cpufreq_stats.c
cpufreq_userspace.c
cpufreq-dt-platdev.c
cpufreq-dt.c
cpufreq-dt.h
cpufreq-nforce2.c
cpufreq.c cpufreq: Cancel policy update work scheduled before freeing 2019-10-22 18:07:30 +02:00
davinci-cpufreq.c
e_powersaver.c
elanfreq.c
freq_table.c
gx-suspmod.c
highbank-cpufreq.c
ia64-acpi-cpufreq.c
imx-cpufreq-dt.c
imx6q-cpufreq.c
intel_pstate.c cpufreq: Use per-policy frequency QoS 2019-10-21 02:05:21 +02:00
Kconfig
Kconfig.arm
Kconfig.powerpc
Kconfig.x86
kirkwood-cpufreq.c
longhaul.c
longhaul.h
longrun.c
loongson1-cpufreq.c
loongson2_cpufreq.c
Makefile
maple-cpufreq.c
mediatek-cpufreq.c
mvebu-cpufreq.c
omap-cpufreq.c
p4-clockmod.c
pasemi-cpufreq.c
pcc-cpufreq.c
pmac32-cpufreq.c
pmac64-cpufreq.c
powernow-k6.c
powernow-k7.c
powernow-k7.h
powernow-k8.c
powernow-k8.h
powernv-cpufreq.c
ppc_cbe_cpufreq_pervasive.c
ppc_cbe_cpufreq_pmi.c cpufreq: Use per-policy frequency QoS 2019-10-21 02:05:21 +02:00
ppc_cbe_cpufreq.c
ppc_cbe_cpufreq.h
pxa2xx-cpufreq.c
pxa3xx-cpufreq.c
qcom-cpufreq-hw.c
qcom-cpufreq-nvmem.c
qoriq-cpufreq.c
raspberrypi-cpufreq.c
s3c24xx-cpufreq-debugfs.c
s3c24xx-cpufreq.c
s3c64xx-cpufreq.c
s3c2410-cpufreq.c
s3c2412-cpufreq.c
s3c2416-cpufreq.c
s3c2440-cpufreq.c
s5pv210-cpufreq.c
sa1100-cpufreq.c
sa1110-cpufreq.c
sc520_freq.c
scmi-cpufreq.c
scpi-cpufreq.c
sfi-cpufreq.c
sh-cpufreq.c
sparc-us2e-cpufreq.c
sparc-us3-cpufreq.c
spear-cpufreq.c
speedstep-centrino.c
speedstep-ich.c
speedstep-lib.c
speedstep-lib.h
speedstep-smi.c
sti-cpufreq.c
sun50i-cpufreq-nvmem.c
tango-cpufreq.c
tegra20-cpufreq.c
tegra124-cpufreq.c
tegra186-cpufreq.c
ti-cpufreq.c
unicore2-cpufreq.c
vexpress-spc-cpufreq.c