Re: [PATCH][next] clk: imx: pll14xx: Fix potential integer overflow on multiplication

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/10/2024 10:54, Dan Carpenter wrote:
On Mon, Oct 07, 2024 at 09:48:40AM +0100, Colin Ian King wrote:
The calculation of fout is using int multiplication and assigning
the result to a u64, this can potentially overflow if the int variable
mdiv is too large. Fix this by making the 65536 a u64 value to ensure a
u64 multiplication is being performed to avoid the overflow.

Fixes: 53990cf9d5b4 ("clk: imx: pll14xx: consolidate rate calculation")
Signed-off-by: Colin Ian King <colin.i.king@xxxxxxxxx>

mdiv is always clamped in then 0-1023 range by one of these:

	mdiv = FIELD_GET(MDIV_MASK, pll_div_ctl0);
	mdiv = clamp(mdiv, 64, 1023);

so it can't overflow and the Fixes tag is unnecessary.

Good point.


I think the reason why "fout" is declared as a u64 is because we were worried
that on 32 bit systems the "fout *=" operation could overflow.  That looks
reasonable to me.

Yes, that makes perfect sense. NAK my patch. Apologies for the noise.

Colin


regards,
dan carpenter






[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux