net: lan9303: fix missing error handling
Subsystems (3)
PATCH 1/1 net: lan9303: fix missing error handling
Both lan9303_phy_write and regmap_write may fail. The fix adds the error handling to print error messages upon failure.
Signed-off-by Kangjie Lu <[email protected]>
--- drivers/net/dsa/lan9303-core.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/dsa/lan9303-core.c +6 -0
@@ -1072,6 +1072,10 @@ static void lan9303_adjust_link(struct dsa_switch *ds, int port, ctl &= ~BMCR_FULLDPLX ; res =lan9303_phy_write (ds, port,MII_BMCR , ctl); +if (res) { +dev_err (ds->dev,"lan9303_phy_write failed: %d\n" , res); +return ; + }if (port == chip->phy_addr_base) {/* Virtual Phy: Remove Turbo 200Mbit mode */
@@ -1080,6 +1084,8 @@ static void lan9303_adjust_link(struct dsa_switch *ds, int port, ctl &= ~LAN9303_VIRT_SPECIAL_TURBO ; res =regmap_write (chip->regmap,LAN9303_VIRT_SPECIAL_CTRL , ctl); +if (res) +dev_err (ds->dev,"regmap_write failed: %d\n" , res); } }
Signature · 1 line
2.17.1
David Miller
maintainerFrom: Kangjie Lu <[email protected]>
Date: Sun, 10 Mar 2019 03:08:56 -0500
Quoted 4 lines
Both
lan9303_phy_writeandregmap_writemay fail. The fix adds the error handling to print error messages upon failure.Signed-off-by Kangjie Lu <[email protected]>
It's ignored elsewhere in this driver in places you haven't handled.
I doubt this is much of an improvement to the driver to be quite honest.
I disagree with the mantra that just because an error is potentially returned, that it always must be checked.