Skip to contentSkip to conversation

fix signedness bug and memory leak in mscc driver

PATCH Superseded Gustavo A. R. Silva 3 participants 8 messages Oct 10, 2018 – Oct 16, 2018

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover fix signedness bug and memory leak in mscc driver

This patchset aims to fix a signedness bug in function vsc85xx_downshift_get() and a memory leak in function vsc8574_config_pre_init().

Changes in v2:
- Add Quentin's Review-by to commit log.
- Jump to out label so all functions in the driver exit with the PHY set to access the standard page. Thanks to Quentin Schulz for pointing this out.

Thanks

Gustavo A. R. Silva (2):
net: phy: mscc: fix signedness bug in vsc85xx_downshift_get
net: phy: mscc: fix memory leak in vsc8574_config_pre_init

 drivers/net/phy/mscc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/2 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")

---
Changes in v2:
- Add Quentin's Reviewed-by to the commit log.

 drivers/net/phy/mscc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/mscc.c +1 -1
index bffe077..bff56c3 100644
@@ -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)
 {
-	u16 reg_val;
+	int reg_val;
 
 	reg_val = phy_read_paged(phydev, MSCC_PHY_PAGE_EXTENDED,
 				 MSCC_PHY_ACTIPHY_CNTL);
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH net-next v2 1/2] net: phy: mscc: fix signedness bug in vsc85xx_downshift_get

Hi,

Quoted 24 lines · Gustavo A. R. Silva

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")

---
Changes in v2:
- Add Quentin's Reviewed-by to the commit log.

 drivers/net/phy/mscc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/mscc.c +0 -0
index bffe077..bff56c3 100644

drivers/net/phy/mscc.c static int vsc85xx_mdix_set(struct phy_device *phydev, u8 mdix) · line 528

Quoted 8 lines
drivers/net/phy/mscc.c +1 -1
@@ -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)
 {
-	u16 reg_val;
+	int reg_val;
 
 	reg_val = phy_read_paged(phydev, MSCC_PHY_PAGE_EXTENDED,
 				 MSCC_PHY_ACTIPHY_CNTL);

Friendly ping. Dave, can you take this?

Thanks!
--
Gustavo

#3 lore raw

PATCH v2 2/2 net: phy: mscc: fix memory leak in vsc8574_config_pre_init

In reply to Gustavo A. R. Silva

In case memory resources for *fw* were successfully allocated, release them before return.

Addresses-Coverity-ID: 1473968 ("Resource leak")

Fixes 00d70d8e0e78 ("net: phy: mscc: add support for VSC8574 PHY")

---
Changes in v2:
- Jump to out label so all functions in the driver exit with the PHY set to access the standard page. Thanks to Quentin Schulz for pointing this out.

 drivers/net/phy/mscc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/mscc.c +1 -1
index bff56c3..a2e59f4 100644
@@ -1292,7 +1292,7 @@ static int vsc8574_config_pre_init(struct phy_device *phydev)
 				dev_err(dev,
 					"%s: failed to assert reset of micro\n",
 					__func__);
-				return ret;
+				goto out;
 			}
 		}
 	} else {
Signature · 1 line
2.7.4
Reviewed-by on v2 2/2
#4 lore raw

Re: [PATCH net-next v2 2/2] net: phy: mscc: fix memory leak in vsc8574_config_pre_init

Hi Gustavo,

Quoted 5 lines · Gustavo A. R. Silva

In case memory resources for *fw* were successfully allocated, release them before return.

Addresses-Coverity-ID: 1473968 ("Resource leak")

Fixes 00d70d8e0e78 ("net: phy: mscc: add support for VSC8574 PHY")

Thanks!
Quentin

#5 lore raw

Re: [PATCH net-next v2 2/2] net: phy: mscc: fix memory leak in vsc8574_config_pre_init

Hi,

Quoted 11 lines · Quentin Schulz

Hi Gustavo,

Quoted 5 lines · Gustavo A. R. Silva

In case memory resources for *fw* were successfully allocated, release them before return.

Addresses-Coverity-ID: 1473968 ("Resource leak")

Fixes 00d70d8e0e78 ("net: phy: mscc: add support for VSC8574 PHY")

Friendly ping. Dave, can you take this?

Thanks!
--
Gustavo

maintainer
#6 lore raw

Re: [PATCH net-next v2 2/2] net: phy: mscc: fix memory leak in vsc8574_config_pre_init

From: "Gustavo A. R. Silva" <[email protected]>
Date: Tue, 16 Oct 2018 10:49:36 +0200

Quoted 9 lines

Hi,

Quoted 6 lines · Quentin Schulz

Hi Gustavo,

Quoted 3 lines · Gustavo A. R. Silva

In case memory resources for *fw* were successfully allocated, release them before return.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Addresses-Coverity-ID: 1473968 ("Resource leak")

Fixes 00d70d8e0e78 ("net: phy: mscc: add support for VSC8574 PHY")

Friendly ping. Dave, can you take this?

It needs to be posted properly to netdev, just like all networking patches do.

#7 lore raw

Re: [PATCH net-next v2 2/2] net: phy: mscc: fix memory leak in vsc8574_config_pre_init

Quoted 6 lines · David Miller
Quoted 2 lines

Friendly ping. Dave, can you take this?

It needs to be posted properly to netdev, just like all networking patches do.

mmh... I don't know how I missed it. :/

OK. I'll send the series to netdev.

Thanks!
--
Gustavo