diff options
author | Lukasz Luba <lukasz.luba@arm.com> | 2024-02-08 14:55:40 +0300 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2024-02-08 17:00:26 +0300 |
commit | 818867224d41725dcf4abe890d8f24e5d6bd9c67 (patch) | |
tree | ae90bc0d1f4430cf54c5bab6a53010e91d162e5c /kernel/power/energy_model.c | |
parent | faf7075b79a259136e2b57ce52b48a7096270e8b (diff) | |
download | linux-818867224d41725dcf4abe890d8f24e5d6bd9c67.tar.xz |
PM: EM: Check if the get_cost() callback is present in em_compute_costs()
Subsequent changes will introduce a case in which 'cb->get_cost' may
not be set in em_compute_costs(), so add a check to ensure that it is
not NULL before attempting to dereference it.
Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Tested-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'kernel/power/energy_model.c')
-rw-r--r-- | kernel/power/energy_model.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c index 5c47caaf270e..21d761223255 100644 --- a/kernel/power/energy_model.c +++ b/kernel/power/energy_model.c @@ -116,7 +116,7 @@ static int em_compute_costs(struct device *dev, struct em_perf_state *table, for (i = nr_states - 1; i >= 0; i--) { unsigned long power_res, cost; - if (flags & EM_PERF_DOMAIN_ARTIFICIAL) { + if ((flags & EM_PERF_DOMAIN_ARTIFICIAL) && cb->get_cost) { ret = cb->get_cost(dev, table[i].frequency, &cost); if (ret || !cost || cost > EM_MAX_POWER) { dev_err(dev, "EM: invalid cost %lu %d\n", |