public inbox for linux-clk@vger.kernel.org
 help / color / mirror / Atom feed
From: Zichen Xie <zichenxie0106@gmail.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: mturquette@baylibre.com, sboyd@kernel.org,
	unicorn_wang@outlook.com, inochiama@outlook.com,
	nathan@kernel.org, linux-clk@vger.kernel.org, zzjas98@gmail.com,
	chenyuan0y@gmail.com
Subject: Re: [PATCH v3] clk: sophgo: Cast an operand to u64 to prevent potential unsigned long overflow on 32-bit machine in sg2042_pll_recalc_rate()
Date: Wed, 23 Oct 2024 08:59:01 -0500	[thread overview]
Message-ID: <e40ee870-fbd4-445f-b1f3-d6f7806f6159@gmail.com> (raw)
In-Reply-To: <13b95ab6-bb38-4b05-9c3f-f567c32cc902@stanley.mountain>


On 2024/10/23 2:41, Dan Carpenter wrote:
> I'm sorry, I have let you down in some ways.  This subject line is too long.
> It's 126 characters long.  Please change it so something like:
>
> clk: sophgo: avoid integer overflow in sg2042_pll_recalc_rate()
>
> On Tue, Oct 22, 2024 at 03:12:45PM -0500, Gax-c wrote:
>> From: Zichen Xie <zichenxie0106@gmail.com>
>>
>> This was found by a static analyzer.
>> There may be a potential integer overflow issue in
>> sg2042_pll_recalc_rate(). numerator is defined as u64 while
>> parent_rate is defined as unsigned long and ctrl_table.fbdiv
>> is defined as unsigned int. On 32-bit machine, the result of
>> the calculation will be limited to "u32" without correct casting.
>> Integer overflow may occur on high-performance systems.
>> We recommended that we cast the denominator as well but
>> Dan Carpenter said that it was a max of 3087 and was not even
>> vaguely close to the 4 billion mark needed to overflow a u32.
>> So, we only cast the numerator here.
> On second though, could we just leave this out.  Let's only mention the
> numerator.

Fine. I'll do it later.


>
> regards,
> dan carpenter
>

      reply	other threads:[~2024-10-23 13:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-22 20:12 [PATCH v3] clk: sophgo: Cast an operand to u64 to prevent potential unsigned long overflow on 32-bit machine in sg2042_pll_recalc_rate() Gax-c
2024-10-23  0:22 ` Chen Wang
2024-10-23  7:41 ` Dan Carpenter
2024-10-23 13:59   ` Zichen Xie [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e40ee870-fbd4-445f-b1f3-d6f7806f6159@gmail.com \
    --to=zichenxie0106@gmail.com \
    --cc=chenyuan0y@gmail.com \
    --cc=dan.carpenter@linaro.org \
    --cc=inochiama@outlook.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=nathan@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=unicorn_wang@outlook.com \
    --cc=zzjas98@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox