From: Florian Fainelli <f.fainelli@gmail.com>
To: "Russell King (Oracle)" <linux@armlinux.org.uk>,
Daniil Dulov <d.dulov@aladdin.ru>
Cc: Jakub Kicinski <kuba@kernel.org>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Doug Berger <opendmb@gmail.com>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
lvc-project@linuxtesting.org
Subject: Re: [PATCH net-next] net: phy: mdio-bcm-unimac: Cast denominator to unsigned long to avoid overflow
Date: Tue, 12 Mar 2024 10:23:06 -0700 [thread overview]
Message-ID: <df295be9-d33e-45d2-914f-c9c1554e5ac0@gmail.com> (raw)
In-Reply-To: <ZfCOb4x/+41y+SW3@shell.armlinux.org.uk>
On 3/12/24 10:18, Russell King (Oracle) wrote:
> On Tue, Mar 12, 2024 at 07:53:58PM +0300, Daniil Dulov wrote:
>> The expression priv->clk_freq * 2 can lead to overflow that will cause
>> a division by zero. So, let's cast it to unsigned long to avoid it.
>
> How does casting this help? "unsigned long" can still be 32-bit.
> Maybe unimac_mdio_probe() should be validating the value it read from
> DT won't overflow? I suspect that a value of 2.1GHz is way too large
> for this property in any case.
>
> https://en.wikipedia.org/wiki/Management_Data_Input/Output#Electrical_specification
>
> (note, this driver is clause-22 only.)
>
Had commented on the previous version (not sure why this was not
prefixed with v2) that the maximum clock frequency for this clock is
250MHz, the driver could check that to prevent for an overflow, most
certainly.
--
Florian
next prev parent reply other threads:[~2024-03-12 17:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-12 16:53 [PATCH net-next] net: phy: mdio-bcm-unimac: Cast denominator to unsigned long to avoid overflow Daniil Dulov
2024-03-12 17:16 ` Jakub Kicinski
2024-03-12 17:18 ` Russell King (Oracle)
2024-03-12 17:23 ` Florian Fainelli [this message]
2024-03-12 19:23 ` Doug Berger
2024-03-12 19:42 ` Russell King (Oracle)
2024-03-12 22:53 ` Doug Berger
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=df295be9-d33e-45d2-914f-c9c1554e5ac0@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=d.dulov@aladdin.ru \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=florian.fainelli@broadcom.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lvc-project@linuxtesting.org \
--cc=netdev@vger.kernel.org \
--cc=opendmb@gmail.com \
--cc=pabeni@redhat.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