lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <695493ae-f8ef-4e25-a194-361436bd7779@roeck-us.net>
Date: Wed, 31 Dec 2025 06:18:26 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: David Laight <david.laight.linux@...il.com>
Cc: SeungJu Cheon <suunj1331@...il.com>, ray.huang@....com,
	linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] hwmon:fam15h_power Use div64_u64() for 64-bit divisor

On Tue, Dec 30, 2025 at 11:23:57PM +0000, David Laight wrote:
> On Tue, 30 Dec 2025 21:09:59 +0900
> SeungJu Cheon <suunj1331@...il.com> wrote:
> 
> > tdelta is u64, but do_div() truncates the divisor to 32 bits.
> > Use div64_u64() to handle the full 64-bit divisor correctly.
> 
> Looking at the code I think that tdelta is a time interval and will
> always fit in 32bits - so the code is probably fine.
> 
Agreed.

> Also I can't see anything that requires jdelta[] be an array.
> Neither can I see the justification for MAX_CUS being 8.
> 
Also agree.

Guenter

> > 
> > Signed-off-by: SeungJu Cheon <suunj1331@...il.com>
> > ---
> >  drivers/hwmon/fam15h_power.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
> > index 8ecebea53651..5e3692606516 100644
> > --- a/drivers/hwmon/fam15h_power.c
> > +++ b/drivers/hwmon/fam15h_power.c
> > @@ -241,7 +241,7 @@ static ssize_t power1_average_show(struct device *dev,
> >  		}
> >  		tdelta = data->cpu_sw_pwr_ptsc[cu] - prev_ptsc[cu];
> >  		jdelta[cu] *= data->cpu_pwr_sample_ratio * 1000;
> > -		do_div(jdelta[cu], tdelta);
> > +		jdelta[cu] = div64_u64(jdelta[cu], tdelta);
> >  
> >  		/* the unit is microWatt */
> >  		avg_acc += jdelta[cu];
> 
> That could be:
> 		jdelta *= data->cpu_pwr_sample_ratio * 1000;
> 		avg_acc += div64_u64(jdelta, tdelta);
> (or even 1 line...)
> 
> 	David
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ