Skip to contentSkip to conversation

net: dsa: mv88e6xxx: fix uninit-value err in mv88e6393x_serdes_power

PATCH In review Jackie Liu 3 participants 3 messages Dec 6, 2021

Subsystems (4)
lore
Share & tools
lore

Jackie Liu

author
#0 lore raw

PATCH 1/1 net: dsa: mv88e6xxx: fix uninit-value err in mv88e6393x_serdes_power

From: Jackie Liu <[email protected]>

'err' is not initialized. If the value of cmode is not in the switch case, it will cause a logic error and return early.

Fixes 7527d66260ac ("net: dsa: mv88e6xxx: Save power by disabling SerDes trasmitter and receiver")
---
 drivers/net/dsa/mv88e6xxx/serdes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/mv88e6xxx/serdes.c +1 -1
index 55273013bfb5..33727439724a 100644
@@ -1507,7 +1507,7 @@ int mv88e6393x_serdes_power(struct mv88e6xxx_chip *chip, int port, int lane,
 			    bool on)
 {
 	u8 cmode = chip->ports[port].cmode;
-	int err;
+	int err = 0;
 
 	if (port != 0 && port != 9 && port != 10)
 		return -EOPNOTSUPP;
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 4 lines · Jackie Liu

From: Jackie Liu <[email protected]>

'err' is not initialized. If the value of cmode is not in the switch case, it will cause a logic error and return early.

Same fix as: <[email protected]>

At least here some analysis has been done why there is a warning.

Should we add a default?

Andrew

#2 lore raw
Quoted 6 lines · On Mon, 6 Dec 2021 14:45:11 +0100 Andrew Lunn <[email protected]> wrote:
Quoted 4 lines · Jackie Liu

From: Jackie Liu <[email protected]>

'err' is not initialized. If the value of cmode is not in the switch case, it will cause a logic error and return early.

Quoted 7 lines

Same fix as: <[email protected]>

At least here some analysis has been done why there is a warning.

Should we add a default?

Andrew

indeed it should be err=0