From: Jakub Kicinski <kuba@kernel.org>
To: Andrew Lunn <andrew@lunn.ch>, Russell King <linux@armlinux.org.uk>
Cc: Dan Carpenter <dan.carpenter@linaro.org>,
Oleksij Rempel <linux@rempel-privat.de>,
Heiner Kallweit <hkallweit1@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH net] net: phy: fix a signedness bug in genphy_loopback()
Date: Mon, 29 May 2023 21:58:02 -0700 [thread overview]
Message-ID: <20230529215802.70710036@kernel.org> (raw)
In-Reply-To: <d7bb312e-2428-45f6-b9b3-59ba544e8b94@kili.mountain>
On Fri, 26 May 2023 14:45:54 +0300 Dan Carpenter wrote:
> The "val" variable is used to store error codes from phy_read() so
> it needs to be signed for the error handling to work as expected.
>
> Fixes: 014068dcb5b1 ("net: phy: genphy_loopback: add link speed configuration")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Is it going to be obvious to PHY-savvy folks that the val passed to
phy_read_poll_timeout() must be an int? Is it a very common pattern?
My outsider intuition is that since regs are 16b, u16 is reasonable,
and more people may make the same mistake. Therefore we should try to
fix phy_read_poll_timeout() instead to use a local variable like it
does for __ret.
Weaker version would be to add a compile time check to ensure val
is signed (assert(typeof(val)~0ULL < 0) or such?).
Opinions?
next prev parent reply other threads:[~2023-05-30 4:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 11:45 [PATCH net] net: phy: fix a signedness bug in genphy_loopback() Dan Carpenter
2023-05-26 11:50 ` Russell King (Oracle)
2023-05-30 4:58 ` Jakub Kicinski [this message]
2023-05-30 9:01 ` Russell King (Oracle)
2023-05-30 9:06 ` Paolo Abeni
2023-05-30 9:23 ` Dan Carpenter
2023-05-30 9:40 ` Paolo Abeni
2023-05-30 9:49 ` Russell King (Oracle)
2023-05-30 10:06 ` Russell King (Oracle)
2023-05-30 12:39 ` Andrew Lunn
2023-05-30 14:40 ` Dan Carpenter
2023-05-30 17:06 ` Andrew Lunn
2023-05-30 19:19 ` Jakub Kicinski
2023-05-30 19:39 ` Russell King (Oracle)
2023-05-30 20:04 ` Andrew Lunn
2023-05-30 21:09 ` Russell King (Oracle)
2023-05-30 21:28 ` Russell King (Oracle)
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=20230529215802.70710036@kernel.org \
--to=kuba@kernel.org \
--cc=andrew@lunn.ch \
--cc=dan.carpenter@linaro.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linux@rempel-privat.de \
--cc=netdev@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).