]> Git Repo - linux.git/commitdiff
net: usb: dm9601: fix wrong return value in dm9601_mdio_read
authorJavier Carrasco <[email protected]>
Sat, 24 Feb 2024 23:20:06 +0000 (00:20 +0100)
committerJakub Kicinski <[email protected]>
Wed, 28 Feb 2024 02:17:23 +0000 (18:17 -0800)
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 <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Reviewed-by: Peter Korsgaard <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
drivers/net/usb/dm9601.c

index 99ec1d4a972db8c1232ce8ee8eb8d97385a9b5f0..8b6d6a1b3c2eca086e77915e26428c1110127f4d 100644 (file)
@@ -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,
This page took 0.060456 seconds and 4 git commands to generate.