Skip to content

Commit f9d0381

Browse files
Javi MerinoEduardo Valentin
authored andcommitted
thermal: power_allocator: req_range multiplication should be a 64 bit type
req_range is declared as a u64 to cope with overflows in the multiplication of two u32. As both req_power and power_range are u32, we need to make sure the multiplication is done with u64 types. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: Zhang Rui <rui.zhang@intel.com> Cc: Eduardo Valentin <edubezval@gmail.com> Signed-off-by: Javi Merino <javi.merino@arm.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
1 parent c0ff8aa commit f9d0381

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/thermal/power_allocator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ static void divvy_up_power(u32 *req_power, u32 *max_power, int num_actors,
301301
capped_extra_power = 0;
302302
extra_power = 0;
303303
for (i = 0; i < num_actors; i++) {
304-
u64 req_range = req_power[i] * power_range;
304+
u64 req_range = (u64)req_power[i] * power_range;
305305

306306
granted_power[i] = DIV_ROUND_CLOSEST_ULL(req_range,
307307
total_req_power);

0 commit comments

Comments
 (0)