Skip to contentSkip to conversation

thermal: power_allocator: req_range multiplication should be a 64 bit type

PATCH RESEND In review Javi Merino 1 participant 3 messages Dec 1, 2015 – Jan 13, 2016 Thermal

lore
Share & tools
lore
#0 lore raw

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
index 1246aa6fcab0..2f1a863a8e15 100644
@@ -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
#1 lore raw

Eduardo, Rui,

Quoted 11 lines · Javi Merino

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(-)

Any comments on this? If not, can it be merged?

Thanks,
Javi

#2 lore raw
Quoted 15 lines · Javi Merino

Eduardo, Rui,

Quoted 11 lines · Javi Merino

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(-)
Quoted 1 line

Any comments on this? If not, can it be merged?

If there are no objections, can this be merged?

Thanks,
Javi