dsa: mv88e6xxx: Fix error handling in mv88e6xxx_set_port_state
Subsystems (3)
PATCH 1/1 dsa: mv88e6xxx: Fix error handling in mv88e6xxx_set_port_state
Return correct error code if _mv88e6xxx_reg_read returns an error.
--- drivers/net/dsa/mv88e6xxx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/dsa/mv88e6xxx.c +3 -1
@@ -908,8 +908,10 @@ static int mv88e6xxx_set_port_state(struct dsa_switch *ds, int port, u8 state)mutex_lock (&ps->smi_mutex); reg =_mv88e6xxx_reg_read (ds,REG_PORT (port),PORT_CONTROL ); -if (reg <0 ) +if (reg <0 ) { + ret = reg; goto abort; + } oldstate = reg &PORT_CONTROL_STATE_MASK ;if (oldstate != state) {
Signature · 1 line
2.1.0
Quoted 4 lines · Guenter Roeck
Return correct error code if
_mv88e6xxx_reg_readreturns an error.Fixes facd95b2e0ec0 ("net: dsa: mv88e6xxx: Add Hardware bridging support")Signed-off-by Guenter Roeck <[email protected]>
Hi Guenter
Good catch. I'm surprised there is no compiler warning, possibly used before set.
Thanks
Andrew
Quoted 27 lines
--- drivers/net/dsa/mv88e6xxx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/dsa/mv88e6xxx.c +3
-1@@ -908,8 +908,10 @@ static int mv88e6xxx_set_port_state(struct dsa_switch *ds, int port, u8 state)mutex_lock (&ps->smi_mutex); reg =_mv88e6xxx_reg_read (ds,REG_PORT (port),PORT_CONTROL ); -if (reg <0 ) +if (reg <0 ) { + ret = reg; goto abort; + } oldstate = reg &PORT_CONTROL_STATE_MASK ;if (oldstate != state) {Signature · 6 lines
2.1.0 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 11 lines · Andrew Lunn
Quoted 4 lines · Guenter Roeck
Return correct error code if
_mv88e6xxx_reg_readreturns an error.Fixes facd95b2e0ec0 ("net: dsa: mv88e6xxx: Add Hardware bridging support")Signed-off-by Guenter Roeck <[email protected]>Hi Guenter
Good catch. I'm surprised there is no compiler warning, possibly used before set.
There was, actually. No idea how I missed that. Fengguang's build bots caught it.
Quoted 2 lines
Reviewed-by Andrew Lunn <[email protected]>
Thanks!
Guenter
Quoted 4 lines · Guenter Roeck
Return correct error code if
_mv88e6xxx_reg_readreturns an error.Fixes facd95b2e0ec0 ("net: dsa: mv88e6xxx: Add Hardware bridging support")Signed-off-by Guenter Roeck <[email protected]>
I should have given proper credit.
For the curious, neither W=1, W=2, C-1, C=2, nor sparse report this problem, at least not with gcc 4.9.1.
Guenter
From: Guenter Roeck <[email protected]>
Date: Wed, 15 Apr 2015 22:12:42 -0700
Quoted 4 lines
Return correct error code if
_mv88e6xxx_reg_readreturns an error.Fixes facd95b2e0ec0 ("net: dsa: mv88e6xxx: Add Hardware bridging support")Signed-off-by Guenter Roeck <[email protected]>
Applied, thanks.
Quoted 9 lines · Guenter Roeck
Quoted 6 lines · Guenter Roeck
Return correct error code if
_mv88e6xxx_reg_readreturns an error.Fixes facd95b2e0ec0 ("net: dsa: mv88e6xxx: Add Hardware bridgingsupport")
Signed-off-by Guenter Roeck <[email protected]>
Quoted 6 lines
I should have given proper credit.
Reported-by kbuild test robot <[email protected]>For the curious, neither W=1, W=2, C-1, C=2, nor sparse report this problem, at least not with gcc 4.9.1.
Good old gcc 4.1.2 (which I still use for m68k builds, and won't retire anytime soon as it finds real bugs in every new kernel release) says:
drivers/net/dsa/mv88e6xxx.c: In function ‘mv88e6xxx_set_port_state’:
drivers/net/dsa/mv88e6xxx.c:905: warning: ‘ret’ may be used
uninitialized in this function
Even after your patch, as it missed one case (patch sent).
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 17 lines · Geert Uytterhoeven
Quoted 9 lines · Guenter Roeck
Quoted 6 lines · Guenter Roeck
Return correct error code if
_mv88e6xxx_reg_readreturns an error.Fixes facd95b2e0ec0 ("net: dsa: mv88e6xxx: Add Hardware bridgingsupport")
Signed-off-by Guenter Roeck <[email protected]>Quoted 6 lines
I should have given proper credit.
Reported-by kbuild test robot <[email protected]>For the curious, neither W=1, W=2, C-1, C=2, nor sparse report this problem, at least not with gcc 4.9.1.
Quoted 9 lines
Good old gcc 4.1.2 (which I still use for m68k builds, and won't retire anytime soon as it finds real bugs in every new kernel release) says:
drivers/net/dsa/mv88e6xxx.c: In function ‘mv88e6xxx_set_port_state’:
drivers/net/dsa/mv88e6xxx.c:905: warning: ‘ret’ may be used
uninitialized in this functionEven after your patch, as it missed one case (patch sent).
Grumble. So much for trusting tools :-(
Thanks for fixing this!
Guenter