Browse Source

net: phy: mscc: fix signedness bug in vsc85xx_downshift_get

Currently, the error handling for the call to function
phy_read_paged() doesn't work because *reg_val* is of
type u16 (16 bits, unsigned), which makes it impossible
for it to hold a value less than 0.

Fix this by changing the type of variable *reg_val* to int.

Addresses-Coverity-ID: 1473970 ("Unsigned compared against 0")
Fixes: 6a0bfbbe20b0 ("net: phy: mscc: migrate to phy_select/restore_page functions")
Reviewed-by: Quentin Schulz <quentin.schulz@bootlin.com>
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Gustavo A. R. Silva 6 years ago
parent
commit
e519869af3
1 changed files with 1 additions and 1 deletions
  1. 1 1
      drivers/net/phy/mscc.c

+ 1 - 1
drivers/net/phy/mscc.c

@@ -522,7 +522,7 @@ static int vsc85xx_mdix_set(struct phy_device *phydev, u8 mdix)
 
 
 static int vsc85xx_downshift_get(struct phy_device *phydev, u8 *count)
 static int vsc85xx_downshift_get(struct phy_device *phydev, u8 *count)
 {
 {
-	u16 reg_val;
+	int reg_val;
 
 
 	reg_val = phy_read_paged(phydev, MSCC_PHY_PAGE_EXTENDED,
 	reg_val = phy_read_paged(phydev, MSCC_PHY_PAGE_EXTENDED,
 				 MSCC_PHY_ACTIPHY_CNTL);
 				 MSCC_PHY_ACTIPHY_CNTL);