thermal: cpu_cooling: don't call kcalloc() under rcu_read_lock
authorJavi Merino <javi.merino@arm.com>
Mon, 17 Aug 2015 18:21:42 +0000 (19:21 +0100)
committerEduardo Valentin <edubezval@gmail.com>
Mon, 14 Sep 2015 03:33:17 +0000 (20:33 -0700)
commit459ac37506d195713b5e82271a2ac44a777e47df
tree7a3071c20fcaa2b5d11b452b1969359ac722b5e6
parent0847e26a84faa0fcb4572d7e42d0a44cab69a83d
thermal: cpu_cooling: don't call kcalloc() under rcu_read_lock

build_dyn_power_table() allocates the power table while holding
rcu_read_lock.  kcalloc using GFP_KERNEL may sleep, so it can't be
called in an RCU read-side path.

Move the rcu protection to the part of the function that really needs
it: the part that handles the dev_pm_opp pointer received from
dev_pm_opp_find_freq_ceil().  In the unlikely case that there is an OPP
added to the cpu while this function is running, return -EAGAIN.

Fixes: c36cf0717631 ("thermal: cpu_cooling: implement the power cooling device API")
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: Javi Merino <javi.merino@arm.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
drivers/thermal/cpu_cooling.c