• Brendan Jackman's avatar
    thermal: cpu_cooling: Fix NULL dereference in cpufreq_state2power · a305a438
    Brendan Jackman authored
    Currently all CPU cooling devices share a
    `struct thermal_cooling_device_ops` instance. The thermal core uses the
    presence of functions in this struct to determine if a cooling device
    has a power model (see cdev_is_power_actor). cpu_cooling.c adds the
    power model functions to the shared struct when a device is registered
    with a power model.
    Therefore, if a CPU cooling device is registered using
    [of_]cpufreq_power_cooling_register, _all_ devices will be determined to
    have a power model, including any registered with
    [of_]cpufreq_cooling_register. This can result in cpufreq_state2power
    being called on a device where dyn_power_table is NULL.
    With this commit, instead of having a shared thermal_cooling_device_ops
    which is mutated, we have two versions: one with the power functions and
    one without.
    Signed-off-by: default avatarBrendan Jackman <brendan.jackman@arm.com>
    Cc: Amit Daniel Kachhap <amit.kachhap@gmail.com>
    Cc: Viresh Kumar <viresh.kumar@linaro.org>
    Cc: Javi Merino <javi.merino@arm.com>
    Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
    Acked-by: default avatarJavi Merino <javi.merino@arm.com>
    Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
cpu_cooling.c 32.5 KB