• Javi Merino's avatar
    thermal: cpu_cooling: don't call kcalloc() under rcu_read_lock · 459ac375
    Javi Merino authored
    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: c36cf071 ("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: default avatarJavi Merino <javi.merino@arm.com>
    Signed-off-by: default avatarEduardo Valentin <edubezval@gmail.com>
    459ac375
cpu_cooling.c 31.7 KB