linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/2] fix signedness bug and memory leak in mscc driver
@ 2018-10-10  8:29 Gustavo A. R. Silva
  2018-10-10  8:30 ` [PATCH net-next v2 1/2] net: phy: mscc: fix signedness bug in vsc85xx_downshift_get Gustavo A. R. Silva
  2018-10-10  8:31 ` [PATCH net-next v2 2/2] net: phy: mscc: fix memory leak in vsc8574_config_pre_init Gustavo A. R. Silva
  0 siblings, 2 replies; 8+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-10  8:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Lunn, Florian Fainelli, David S. Miller, Quentin Schulz,
	Gustavo A. R. Silva

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

-- 
2.7.4


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH net-next v2 1/2] net: phy: mscc: fix signedness bug in vsc85xx_downshift_get
  2018-10-10  8:29 [PATCH net-next v2 0/2] fix signedness bug and memory leak in mscc driver Gustavo A. R. Silva
@ 2018-10-10  8:30 ` Gustavo A. R. Silva
  2018-10-16  8:51   ` Gustavo A. R. Silva
  2018-10-10  8:31 ` [PATCH net-next v2 2/2] net: phy: mscc: fix memory leak in vsc8574_config_pre_init Gustavo A. R. Silva
  1 sibling, 1 reply; 8+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-10  8:30 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Lunn, Florian Fainelli, David S. Miller, Quentin Schulz,
	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")
Reviewed-by: Quentin Schulz <quentin.schulz@bootlin.com>
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
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(-)

diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c
index bffe077..bff56c3 100644
--- a/drivers/net/phy/mscc.c
+++ b/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)
 {
-	u16 reg_val;
+	int reg_val;
 
 	reg_val = phy_read_paged(phydev, MSCC_PHY_PAGE_EXTENDED,
 				 MSCC_PHY_ACTIPHY_CNTL);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net-next v2 2/2] net: phy: mscc: fix memory leak in vsc8574_config_pre_init
  2018-10-10  8:29 [PATCH net-next v2 0/2] fix signedness bug and memory leak in mscc driver Gustavo A. R. Silva
  2018-10-10  8:30 ` [PATCH net-next v2 1/2] net: phy: mscc: fix signedness bug in vsc85xx_downshift_get Gustavo A. R. Silva
@ 2018-10-10  8:31 ` Gustavo A. R. Silva
  2018-10-10  8:34   ` Quentin Schulz
  1 sibling, 1 reply; 8+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-10  8:31 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Lunn, Florian Fainelli, David S. Miller, Quentin Schulz,
	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")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
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(-)

diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c
index bff56c3..a2e59f4 100644
--- a/drivers/net/phy/mscc.c
+++ b/drivers/net/phy/mscc.c
@@ -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 {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next v2 2/2] net: phy: mscc: fix memory leak in vsc8574_config_pre_init
  2018-10-10  8:31 ` [PATCH net-next v2 2/2] net: phy: mscc: fix memory leak in vsc8574_config_pre_init Gustavo A. R. Silva
@ 2018-10-10  8:34   ` Quentin Schulz
  2018-10-16  8:49     ` Gustavo A. R. Silva
  0 siblings, 1 reply; 8+ messages in thread
From: Quentin Schulz @ 2018-10-10  8:34 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: linux-kernel, Andrew Lunn, Florian Fainelli, David S. Miller

[-- Attachment #1: Type: text/plain, Size: 389 bytes --]

Hi Gustavo,

On Wed, Oct 10, 2018 at 10:31:39AM +0200, Gustavo A. R. Silva wrote:
> 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")

Reviewed-by: Quentin Schulz <quentin.schulz@bootlin.com>

Thanks!
Quentin

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next v2 2/2] net: phy: mscc: fix memory leak in vsc8574_config_pre_init
  2018-10-10  8:34   ` Quentin Schulz
@ 2018-10-16  8:49     ` Gustavo A. R. Silva
  2018-10-16 16:54       ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-16  8:49 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: linux-kernel, Andrew Lunn, Florian Fainelli, David S. Miller

Hi,

On 10/10/18 10:34 AM, Quentin Schulz wrote:
> Hi Gustavo,
> 
> On Wed, Oct 10, 2018 at 10:31:39AM +0200, Gustavo A. R. Silva wrote:
>> 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")
> 
> Reviewed-by: Quentin Schulz <quentin.schulz@bootlin.com>
> 

Friendly ping. Dave, can you take this?

Thanks!
--
Gustavo

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next v2 1/2] net: phy: mscc: fix signedness bug in vsc85xx_downshift_get
  2018-10-10  8:30 ` [PATCH net-next v2 1/2] net: phy: mscc: fix signedness bug in vsc85xx_downshift_get Gustavo A. R. Silva
@ 2018-10-16  8:51   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 8+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-16  8:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Andrew Lunn, Florian Fainelli, David S. Miller, Quentin Schulz

Hi,

On 10/10/18 10:30 AM, Gustavo A. R. Silva wrote:
> 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>
> ---
> 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(-)
> 
> diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c
> index bffe077..bff56c3 100644
> --- a/drivers/net/phy/mscc.c
> +++ b/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)
>  {
> -	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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next v2 2/2] net: phy: mscc: fix memory leak in vsc8574_config_pre_init
  2018-10-16  8:49     ` Gustavo A. R. Silva
@ 2018-10-16 16:54       ` David Miller
  2018-10-16 17:03         ` Gustavo A. R. Silva
  0 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2018-10-16 16:54 UTC (permalink / raw)
  To: gustavo; +Cc: quentin.schulz, linux-kernel, andrew, f.fainelli

From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date: Tue, 16 Oct 2018 10:49:36 +0200

> Hi,
> 
> On 10/10/18 10:34 AM, Quentin Schulz wrote:
>> Hi Gustavo,
>> 
>> On Wed, Oct 10, 2018 at 10:31:39AM +0200, Gustavo A. R. Silva wrote:
>>> 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")
>> 
>> Reviewed-by: Quentin Schulz <quentin.schulz@bootlin.com>
>> 
> 
> Friendly ping. Dave, can you take this?

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next v2 2/2] net: phy: mscc: fix memory leak in vsc8574_config_pre_init
  2018-10-16 16:54       ` David Miller
@ 2018-10-16 17:03         ` Gustavo A. R. Silva
  0 siblings, 0 replies; 8+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-16 17:03 UTC (permalink / raw)
  To: David Miller; +Cc: quentin.schulz, linux-kernel, andrew, f.fainelli



On 10/16/18 6:54 PM, David Miller wrote:
>>
>> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-10-16 17:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-10  8:29 [PATCH net-next v2 0/2] fix signedness bug and memory leak in mscc driver Gustavo A. R. Silva
2018-10-10  8:30 ` [PATCH net-next v2 1/2] net: phy: mscc: fix signedness bug in vsc85xx_downshift_get Gustavo A. R. Silva
2018-10-16  8:51   ` Gustavo A. R. Silva
2018-10-10  8:31 ` [PATCH net-next v2 2/2] net: phy: mscc: fix memory leak in vsc8574_config_pre_init Gustavo A. R. Silva
2018-10-10  8:34   ` Quentin Schulz
2018-10-16  8:49     ` Gustavo A. R. Silva
2018-10-16 16:54       ` David Miller
2018-10-16 17:03         ` Gustavo A. R. Silva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).