net: dsa: mv88e6xxx: fix uninit-value err in mv88e6393x_serdes_power
Subsystems (4)
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.
--- drivers/net/dsa/mv88e6xxx/serdes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/mv88e6xxx/serdes.c +1 -1
@@ -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
Andrew Lunn
maintainerQuoted 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
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