diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2020-09-30 09:19:58 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-10-02 06:00:12 +0200 |
commit | 4dd5c073c750618054fd4366dcf141770559af46 (patch) | |
tree | 80d663452fc4b66a959a9acf677c7e121a013660 /drivers/net/usb | |
parent | f245581eb865c1ed62fb6b8a382ab7bf6b0f6d38 (diff) | |
download | barebox-4dd5c073c750618054fd4366dcf141770559af46.tar.gz barebox-4dd5c073c750618054fd4366dcf141770559af46.tar.xz |
net: usb: asix: propagate errors from MDIO accessors
The primitives asix_mdio_write and asix_mdio_read use return errors, but
are unchecked. Propagate them instead.
Reported-by: clang-analyzer-10
[afa: Untested on real hardware]
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r-- | drivers/net/usb/asix.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c index 3ca27ff027..1140be9d16 100644 --- a/drivers/net/usb/asix.c +++ b/drivers/net/usb/asix.c @@ -252,11 +252,19 @@ static int asix_mdio_read(struct mii_bus *bus, int phy_id, int loc) { struct usbnet *dev = bus->priv; __le16 res; + int ret; - asix_set_sw_mii(dev); - asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, - (__u16)loc, 2, &res); - asix_set_hw_mii(dev); + ret = asix_set_sw_mii(dev); + if (ret < 0) + return ret; + + ret = asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, (__u16)loc, 2, &res); + if (ret < 0) + return ret; + + ret = asix_set_hw_mii(dev); + if (ret < 0) + return ret; dev_dbg(&dev->edev.dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n", phy_id, loc, le16_to_cpu(res)); @@ -268,13 +276,22 @@ static int asix_mdio_write(struct mii_bus *bus, int phy_id, int loc, u16 val) { struct usbnet *dev = bus->priv; __le16 res = cpu_to_le16(val); + int ret; dev_dbg(&dev->edev.dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n", phy_id, loc, val); - asix_set_sw_mii(dev); - asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res); - asix_set_hw_mii(dev); + ret = asix_set_sw_mii(dev); + if (ret < 0) + return ret; + + ret = asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res); + if (ret < 0) + return ret; + + ret = asix_set_hw_mii(dev); + if (ret < 0) + return ret; return 0; } |