diff mbox

[RESEND] thermal: power_allocator: req_range multiplication should be a 64 bit type

Message ID 1448982923-19416-1-git-send-email-javi.merino@arm.com (mailing list archive)
State Accepted, archived
Delegated to: Zhang Rui
Headers show

Commit Message

Javi Merino Dec. 1, 2015, 3:15 p.m. UTC
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>
---
 drivers/thermal/power_allocator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Javi Merino Dec. 19, 2015, 1:49 p.m. UTC | #1
Eduardo, Rui,

On Tue, Dec 01, 2015 at 03:15:23PM +0000, Javi Merino wrote:
> 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>
> ---
>  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
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Javi Merino Jan. 13, 2016, 4:10 p.m. UTC | #2
On Sat, Dec 19, 2015 at 01:49:58PM +0000, Javi Merino wrote:
> Eduardo, Rui,
> 
> On Tue, Dec 01, 2015 at 03:15:23PM +0000, Javi Merino wrote:
> > 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>
> > ---
> >  drivers/thermal/power_allocator.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Any comments on this?  If not, can it be merged?

If there are no objections, can this be merged?

Thanks,
Javi
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/thermal/power_allocator.c b/drivers/thermal/power_allocator.c
index 1246aa6fcab0..2f1a863a8e15 100644
--- a/drivers/thermal/power_allocator.c
+++ b/drivers/thermal/power_allocator.c
@@ -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);