All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: sky2: initialize return of gm_phy_read
@ 2020-07-03 13:33 trix
  2020-07-03 13:53 ` Andrew Lunn
  2020-07-07 22:24 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: trix @ 2020-07-03 13:33 UTC (permalink / raw)
  To: mlindner, stephen, davem, kuba; +Cc: netdev, linux-kernel, Tom Rix

From: Tom Rix <trix@redhat.com>

clang static analysis flags this garbage return

drivers/net/ethernet/marvell/sky2.c:208:2: warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn]
        return v;
        ^~~~~~~~

static inline u16 gm_phy_read( ...
{
	u16 v;
	__gm_phy_read(hw, port, reg, &v);
	return v;
}

__gm_phy_read can return without setting v.

So handle similar to skge.c's gm_phy_read, initialize v.

Signed-off-by: Tom Rix <trix@redhat.com>
---
 drivers/net/ethernet/marvell/sky2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index 241f00716979..fe54764caea9 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -203,7 +203,7 @@ static int __gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg, u16 *val)
 
 static inline u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)
 {
-	u16 v;
+	u16 v = 0;
 	__gm_phy_read(hw, port, reg, &v);
 	return v;
 }
-- 
2.18.1


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

* Re: [PATCH] net: sky2: initialize return of gm_phy_read
  2020-07-03 13:33 [PATCH] net: sky2: initialize return of gm_phy_read trix
@ 2020-07-03 13:53 ` Andrew Lunn
  2020-07-07 22:24 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2020-07-03 13:53 UTC (permalink / raw)
  To: trix; +Cc: mlindner, stephen, davem, kuba, netdev, linux-kernel

On Fri, Jul 03, 2020 at 06:33:59AM -0700, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
> 
> clang static analysis flags this garbage return
> 
> drivers/net/ethernet/marvell/sky2.c:208:2: warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn]
>         return v;
>         ^~~~~~~~
> 
> static inline u16 gm_phy_read( ...
> {
> 	u16 v;
> 	__gm_phy_read(hw, port, reg, &v);
> 	return v;
> }
> 
> __gm_phy_read can return without setting v.
> 
> So handle similar to skge.c's gm_phy_read, initialize v.
> 
> Signed-off-by: Tom Rix <trix@redhat.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH] net: sky2: initialize return of gm_phy_read
  2020-07-03 13:33 [PATCH] net: sky2: initialize return of gm_phy_read trix
  2020-07-03 13:53 ` Andrew Lunn
@ 2020-07-07 22:24 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-07-07 22:24 UTC (permalink / raw)
  To: trix; +Cc: mlindner, stephen, kuba, netdev, linux-kernel

From: trix@redhat.com
Date: Fri,  3 Jul 2020 06:33:59 -0700

> From: Tom Rix <trix@redhat.com>
> 
> clang static analysis flags this garbage return
> 
> drivers/net/ethernet/marvell/sky2.c:208:2: warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn]
>         return v;
>         ^~~~~~~~
> 
> static inline u16 gm_phy_read( ...
> {
> 	u16 v;
> 	__gm_phy_read(hw, port, reg, &v);
> 	return v;
> }
> 
> __gm_phy_read can return without setting v.
> 
> So handle similar to skge.c's gm_phy_read, initialize v.
> 
> Signed-off-by: Tom Rix <trix@redhat.com>

Applied, thank you.

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

end of thread, other threads:[~2020-07-07 22:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-03 13:33 [PATCH] net: sky2: initialize return of gm_phy_read trix
2020-07-03 13:53 ` Andrew Lunn
2020-07-07 22:24 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.