Skip to content

Commit e5d1c87

Browse files
Nikita Zhandarovichrafaeljw
authored andcommitted
PM: domains: fix integer overflow issues in genpd_parse_state()
Currently, while calculating residency and latency values, right operands may overflow if resulting values are big enough. To prevent this, albeit unlikely case, play it safe and convert right operands to left ones' type s64. Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE. Fixes: 30f6042 ("PM / Domains: Allow domain power states to be read from DT") Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru> Acked-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 44c026a commit e5d1c87

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/base/power/domain.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2939,10 +2939,10 @@ static int genpd_parse_state(struct genpd_power_state *genpd_state,
29392939

29402940
err = of_property_read_u32(state_node, "min-residency-us", &residency);
29412941
if (!err)
2942-
genpd_state->residency_ns = 1000 * residency;
2942+
genpd_state->residency_ns = 1000LL * residency;
29432943

2944-
genpd_state->power_on_latency_ns = 1000 * exit_latency;
2945-
genpd_state->power_off_latency_ns = 1000 * entry_latency;
2944+
genpd_state->power_on_latency_ns = 1000LL * exit_latency;
2945+
genpd_state->power_off_latency_ns = 1000LL * entry_latency;
29462946
genpd_state->fwnode = &state_node->fwnode;
29472947

29482948
return 0;

0 commit comments

Comments
 (0)