thermal: power_allocator: req_range multiplication should be a 64 bit type
PATCH RESEND 1/1 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.
--- drivers/thermal/power_allocator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/power_allocator.c +1 -1
@@ -301,7 +301,7 @@ static void divvy_up_power(u32 *req_power, u32 *max_power, int num_actors, capped_extra_power =0 ; extra_power =0 ;for (i =0 ; i < num_actors; i++) { -u64 req_range = req_power[i] * power_range; +u64 req_range = (u64 )req_power[i] * power_range; granted_power[i] =DIV_ROUND_CLOSEST_ULL (req_range, total_req_power);
Signature · 1 line
1.9.1
Eduardo, Rui,
Quoted 11 lines · Javi Merino
req_rangeis declared as a u64 to cope with overflows in the multiplication of two u32. As bothreq_powerandpower_rangeare u32, we need to make sure the multiplication is done with u64 types.Reported-by Dan Carpenter <[email protected]>Cc Zhang Rui <[email protected]>Cc Eduardo Valentin <[email protected]>Signed-off-by Javi Merino <[email protected]>--- drivers/thermal/power_allocator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Any comments on this? If not, can it be merged?
Thanks,
Javi
Quoted 15 lines · Javi Merino
Eduardo, Rui,
Quoted 11 lines · Javi Merino
req_rangeis declared as a u64 to cope with overflows in the multiplication of two u32. As bothreq_powerandpower_rangeare u32, we need to make sure the multiplication is done with u64 types.Reported-by Dan Carpenter <[email protected]>Cc Zhang Rui <[email protected]>Cc Eduardo Valentin <[email protected]>Signed-off-by Javi Merino <[email protected]>--- drivers/thermal/power_allocator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 1 line
Any comments on this? If not, can it be merged?
If there are no objections, can this be merged?
Thanks,
Javi