Skip to contentSkip to conversation

net: sky2: initialize return of gm_phy_read

PATCH Applied [email protected] 3 participants 3 messages Jul 3, 2020 – Jul 7, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: sky2: initialize return of gm_phy_read

From: Tom Rix <[email protected]>

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.

---
 drivers/net/ethernet/marvell/sky2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/sky2.c +1 -1
index 241f00716979..fe54764caea9 100644
@@ -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;
 }
Signature · 1 line
2.18.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · On Fri, Jul 03, 2020 at 06:33:59AM -0700, [email protected] wrote:

From: Tom Rix <[email protected]>

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;
}
Quoted 5 lines

__gm_phy_read can return without setting v.

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

Andrew

maintainer Applied
#2 lore raw
In reply to [email protected]

From: [email protected]
Date: Fri, 3 Jul 2020 06:33:59 -0700

Quoted 15 lines

From: Tom Rix <[email protected]>

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;
}
Quoted 5 lines

__gm_phy_read can return without setting v.

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

Applied, thank you.