From: Nikita Zhandarovich Date: Tue, 18 Apr 2023 13:07:43 +0000 (-0700) Subject: PM: domains: fix integer overflow issues in genpd_parse_state() X-Git-Tag: v6.1.39~546 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6368a71dca09a227f26509b7e96d8a49aaf16ac8;p=platform%2Fkernel%2Flinux-starfive.git PM: domains: fix integer overflow issues in genpd_parse_state() [ Upstream commit e5d1c8722083f0332dcd3c85fa1273d85fb6bed8 ] 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: 30f604283e05 ("PM / Domains: Allow domain power states to be read from DT") Signed-off-by: Nikita Zhandarovich Acked-by: Ulf Hansson Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index b411201..b33fc32 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2923,10 +2923,10 @@ static int genpd_parse_state(struct genpd_power_state *genpd_state, err = of_property_read_u32(state_node, "min-residency-us", &residency); if (!err) - genpd_state->residency_ns = 1000 * residency; + genpd_state->residency_ns = 1000LL * residency; - genpd_state->power_on_latency_ns = 1000 * exit_latency; - genpd_state->power_off_latency_ns = 1000 * entry_latency; + genpd_state->power_on_latency_ns = 1000LL * exit_latency; + genpd_state->power_off_latency_ns = 1000LL * entry_latency; genpd_state->fwnode = &state_node->fwnode; return 0;