net:phy: Add a return value check on bus write
diff mbox series

Message ID 20181226173717.7113-1-pakki001@umn.edu
State New
Headers show
Series
  • net:phy: Add a return value check on bus write
Related show

Commit Message

Aditya Pakki Dec. 26, 2018, 5:37 p.m. UTC
xgmiitorgmii_read_status() could fail when writing to the bus via
mdiobus_write(). The fix adds a check and returns an error in case
of failure.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 drivers/net/phy/xilinx_gmii2rgmii.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Heiner Kallweit Dec. 26, 2018, 5:44 p.m. UTC | #1
On 26.12.2018 18:37, Aditya Pakki wrote:
> xgmiitorgmii_read_status() could fail when writing to the bus via
> mdiobus_write(). The fix adds a check and returns an error in case
> of failure.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>  drivers/net/phy/xilinx_gmii2rgmii.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c b/drivers/net/phy/xilinx_gmii2rgmii.c
> index 74a8782313cf..926879d43373 100644
> --- a/drivers/net/phy/xilinx_gmii2rgmii.c
> +++ b/drivers/net/phy/xilinx_gmii2rgmii.c
> @@ -58,7 +58,9 @@ static int xgmiitorgmii_read_status(struct phy_device *phydev)
>  	else
>  		val |= BMCR_SPEED10;
>  
> -	mdiobus_write(bus, addr, XILINX_GMII2RGMII_REG, val);
> +	err = mdiobus_write(bus, addr, XILINX_GMII2RGMII_REG, val);
> +	if (err)
> +		return err;
>  
>  	return 0;
Why not simply:
return mdiobus_write(bus, addr, XILINX_GMII2RGMII_REG, val);

Heiner
Heiner Kallweit Dec. 26, 2018, 5:50 p.m. UTC | #2
On 26.12.2018 18:37, Aditya Pakki wrote:
> xgmiitorgmii_read_status() could fail when writing to the bus via
> mdiobus_write(). The fix adds a check and returns an error in case
> of failure.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---

Two more things:
- subject should be: "net: phy: xgmiitorgmii: check bus write return value"
  See also git history of this file.
- patch needs to be properly annotated as "net" or "net-next".
  net-next is closed currently, please re-submit once it's open again in
  ~ 2-3 weeks.

Heiner

Patch
diff mbox series

diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c b/drivers/net/phy/xilinx_gmii2rgmii.c
index 74a8782313cf..926879d43373 100644
--- a/drivers/net/phy/xilinx_gmii2rgmii.c
+++ b/drivers/net/phy/xilinx_gmii2rgmii.c
@@ -58,7 +58,9 @@  static int xgmiitorgmii_read_status(struct phy_device *phydev)
 	else
 		val |= BMCR_SPEED10;
 
-	mdiobus_write(bus, addr, XILINX_GMII2RGMII_REG, val);
+	err = mdiobus_write(bus, addr, XILINX_GMII2RGMII_REG, val);
+	if (err)
+		return err;
 
 	return 0;
 }