* [PATCH] net: usb: dm9601: fix wrong return value in dm9601_mdio_read
@ 2024-02-24 23:20 Javier Carrasco
2024-02-27 16:09 ` Simon Horman
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Javier Carrasco @ 2024-02-24 23:20 UTC (permalink / raw)
To: Peter Korsgaard, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: netdev, linux-usb, linux-kernel, Javier Carrasco
The MII code does not check the return value of mdio_read (among
others), and therefore no error code should be sent. A previous fix to
the use of an uninitialized variable propagates negative error codes,
that might lead to wrong operations by the MII library.
An example of such issues is the use of mii_nway_restart by the dm9601
driver. The mii_nway_restart function does not check the value returned
by mdio_read, which in this case might be a negative number which could
contain the exact bit the function checks (BMCR_ANENABLE = 0x1000).
Return zero in case of error, as it is common practice in users of
mdio_read to avoid wrong uses of the return value.
Fixes: 8f8abb863fa5 ("net: usb: dm9601: fix uninitialized variable use in dm9601_mdio_read")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
drivers/net/usb/dm9601.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index 99ec1d4a972d..8b6d6a1b3c2e 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -232,7 +232,7 @@ static int dm9601_mdio_read(struct net_device *netdev, int phy_id, int loc)
err = dm_read_shared_word(dev, 1, loc, &res);
if (err < 0) {
netdev_err(dev->net, "MDIO read error: %d\n", err);
- return err;
+ return 0;
}
netdev_dbg(dev->net,
---
base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d
change-id: 20240224-dm9601_ret_err-0a9c9d95cd10
Best regards,
--
Javier Carrasco <javier.carrasco.cruz@gmail.com>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] net: usb: dm9601: fix wrong return value in dm9601_mdio_read
2024-02-24 23:20 [PATCH] net: usb: dm9601: fix wrong return value in dm9601_mdio_read Javier Carrasco
@ 2024-02-27 16:09 ` Simon Horman
2024-02-27 16:53 ` Peter Korsgaard
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2024-02-27 16:09 UTC (permalink / raw)
To: Javier Carrasco
Cc: Peter Korsgaard, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, netdev, linux-usb, linux-kernel
On Sun, Feb 25, 2024 at 12:20:06AM +0100, Javier Carrasco wrote:
> The MII code does not check the return value of mdio_read (among
> others), and therefore no error code should be sent. A previous fix to
> the use of an uninitialized variable propagates negative error codes,
> that might lead to wrong operations by the MII library.
>
> An example of such issues is the use of mii_nway_restart by the dm9601
> driver. The mii_nway_restart function does not check the value returned
> by mdio_read, which in this case might be a negative number which could
> contain the exact bit the function checks (BMCR_ANENABLE = 0x1000).
>
> Return zero in case of error, as it is common practice in users of
> mdio_read to avoid wrong uses of the return value.
>
> Fixes: 8f8abb863fa5 ("net: usb: dm9601: fix uninitialized variable use in dm9601_mdio_read")
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
I guess it would be nice if error values could be used,
but as you have described, that does not seem to be the case here.
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: usb: dm9601: fix wrong return value in dm9601_mdio_read
2024-02-24 23:20 [PATCH] net: usb: dm9601: fix wrong return value in dm9601_mdio_read Javier Carrasco
2024-02-27 16:09 ` Simon Horman
@ 2024-02-27 16:53 ` Peter Korsgaard
2024-02-28 2:17 ` Jakub Kicinski
2024-02-28 3:20 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 6+ messages in thread
From: Peter Korsgaard @ 2024-02-27 16:53 UTC (permalink / raw)
To: Javier Carrasco
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev, linux-usb, linux-kernel
>>>>> "Javier" == Javier Carrasco <javier.carrasco.cruz@gmail.com> writes:
> The MII code does not check the return value of mdio_read (among
> others), and therefore no error code should be sent. A previous fix to
> the use of an uninitialized variable propagates negative error codes,
> that might lead to wrong operations by the MII library.
> An example of such issues is the use of mii_nway_restart by the dm9601
> driver. The mii_nway_restart function does not check the value returned
> by mdio_read, which in this case might be a negative number which could
> contain the exact bit the function checks (BMCR_ANENABLE = 0x1000).
> Return zero in case of error, as it is common practice in users of
> mdio_read to avoid wrong uses of the return value.
> Fixes: 8f8abb863fa5 ("net: usb: dm9601: fix uninitialized variable use in dm9601_mdio_read")
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Reviewed-by: Peter Korsgaard <peter@korsgaard.com>
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: usb: dm9601: fix wrong return value in dm9601_mdio_read
2024-02-24 23:20 [PATCH] net: usb: dm9601: fix wrong return value in dm9601_mdio_read Javier Carrasco
2024-02-27 16:09 ` Simon Horman
2024-02-27 16:53 ` Peter Korsgaard
@ 2024-02-28 2:17 ` Jakub Kicinski
2024-02-28 15:10 ` Andrew Lunn
2024-02-28 3:20 ` patchwork-bot+netdevbpf
3 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2024-02-28 2:17 UTC (permalink / raw)
To: Javier Carrasco, Andrew Lunn
Cc: Peter Korsgaard, David S. Miller, Eric Dumazet, Paolo Abeni,
netdev, linux-usb, linux-kernel
On Sun, 25 Feb 2024 00:20:06 +0100 Javier Carrasco wrote:
> The MII code does not check the return value of mdio_read (among
> others), and therefore no error code should be sent. A previous fix to
> the use of an uninitialized variable propagates negative error codes,
> that might lead to wrong operations by the MII library.
>
> An example of such issues is the use of mii_nway_restart by the dm9601
> driver. The mii_nway_restart function does not check the value returned
> by mdio_read, which in this case might be a negative number which could
> contain the exact bit the function checks (BMCR_ANENABLE = 0x1000).
>
> Return zero in case of error, as it is common practice in users of
> mdio_read to avoid wrong uses of the return value.
A bit odd but appears to be true, so I'll apply, thank you!
Andrew,
mii.h files seem to fall under PHYLIB in MAINTAINERS, but mii.c does
not. Is this intentional?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: usb: dm9601: fix wrong return value in dm9601_mdio_read
2024-02-24 23:20 [PATCH] net: usb: dm9601: fix wrong return value in dm9601_mdio_read Javier Carrasco
` (2 preceding siblings ...)
2024-02-28 2:17 ` Jakub Kicinski
@ 2024-02-28 3:20 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-02-28 3:20 UTC (permalink / raw)
To: Javier Carrasco
Cc: peter, davem, edumazet, kuba, pabeni, netdev, linux-usb,
linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sun, 25 Feb 2024 00:20:06 +0100 you wrote:
> The MII code does not check the return value of mdio_read (among
> others), and therefore no error code should be sent. A previous fix to
> the use of an uninitialized variable propagates negative error codes,
> that might lead to wrong operations by the MII library.
>
> An example of such issues is the use of mii_nway_restart by the dm9601
> driver. The mii_nway_restart function does not check the value returned
> by mdio_read, which in this case might be a negative number which could
> contain the exact bit the function checks (BMCR_ANENABLE = 0x1000).
>
> [...]
Here is the summary with links:
- net: usb: dm9601: fix wrong return value in dm9601_mdio_read
https://git.kernel.org/netdev/net/c/c68b2c9eba38
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: usb: dm9601: fix wrong return value in dm9601_mdio_read
2024-02-28 2:17 ` Jakub Kicinski
@ 2024-02-28 15:10 ` Andrew Lunn
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2024-02-28 15:10 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Javier Carrasco, Peter Korsgaard, David S. Miller, Eric Dumazet,
Paolo Abeni, netdev, linux-usb, linux-kernel
> Andrew,
> mii.h files seem to fall under PHYLIB in MAINTAINERS, but mii.c does
> not. Is this intentional?
Probably. There are big parts of linux/mii.h which phylib
uses. However drivers/net/mii.c is not part of phylib and is
unmaintained.
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-02-28 15:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-24 23:20 [PATCH] net: usb: dm9601: fix wrong return value in dm9601_mdio_read Javier Carrasco
2024-02-27 16:09 ` Simon Horman
2024-02-27 16:53 ` Peter Korsgaard
2024-02-28 2:17 ` Jakub Kicinski
2024-02-28 15:10 ` Andrew Lunn
2024-02-28 3:20 ` patchwork-bot+netdevbpf
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).