History

net: dsa: mt7530: check bus->read() errors in the MDIO regmap backend

bus->read() returns a negative errno on failure, but mt7530_regmap_read() assigns it to a u16, truncating e.g. -ETIMEDOUT into 0xff92, and returns success. The garbage word is then consumed as register data, and read-modify-write cycles write it back to the switch. Check both reads and propagate their errors. The same defect existed in mt7530_mii_read() since the driver was introduced and moved into the regmap backend unchanged.

Daniel Golle committed 3 months ago

Commit b4ce1021 parent 47fa6791 file · +9 −2Browse files

Unified · Split

drivers/net/dsa/mt7530-mdio.c+9−2
@@ -55,8 +55,15 @@ mt7530_regmap_read(void *context, unsigned int reg, unsigned int *val) · 54 unmodified lines
5555 if (ret < 0)
5656 return ret;
5757
58− lo = bus->read(bus, priv->mdiodev->addr, r);
59− hi = bus->read(bus, priv->mdiodev->addr, 0x10);
58+ ret = bus->read(bus, priv->mdiodev->addr, r);
59+ if (ret < 0)
60+ return ret;
61+ lo = ret;
62+
63+ ret = bus->read(bus, priv->mdiodev->addr, 0x10);
64+ if (ret < 0)
65+ return ret;
66+ hi = ret;
6067
6168 *val = (hi << 16) | (lo & 0xffff);
6269

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t