diff mbox series

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

Message ID 20211206101352.2713117-1-liu.yun@linux.dev (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: mv88e6xxx: fix uninit-value err in mv88e6393x_serdes_power | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 5 maintainers not CCed: vivien.didelot@gmail.com andrew@lunn.ch f.fainelli@gmail.com olteanv@gmail.com kuba@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jackie Liu Dec. 6, 2021, 10:13 a.m. UTC
From: Jackie Liu <liuyun01@kylinos.cn>

'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")
Reported-by: kernel-bot <kernel-robot@kylinos.cn>
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
---
 drivers/net/dsa/mv88e6xxx/serdes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Lunn Dec. 6, 2021, 1:45 p.m. UTC | #1
On Mon, Dec 06, 2021 at 06:13:52PM +0800, Jackie Liu wrote:
> From: Jackie Liu <liuyun01@kylinos.cn>
> 
> '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: <20211206113219.17640-1-amhamza.mgc@gmail.com>

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

Should we add a default?

       Andrew
Marek Behún Dec. 6, 2021, 6:50 p.m. UTC | #2
On Mon, 6 Dec 2021 14:45:11 +0100
Andrew Lunn <andrew@lunn.ch> wrote:

> On Mon, Dec 06, 2021 at 06:13:52PM +0800, Jackie Liu wrote:
> > From: Jackie Liu <liuyun01@kylinos.cn>
> > 
> > '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: <20211206113219.17640-1-amhamza.mgc@gmail.com>
> 
> 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
diff mbox series

Patch

diff --git a/drivers/net/dsa/mv88e6xxx/serdes.c b/drivers/net/dsa/mv88e6xxx/serdes.c
index 55273013bfb5..33727439724a 100644
--- a/drivers/net/dsa/mv88e6xxx/serdes.c
+++ b/drivers/net/dsa/mv88e6xxx/serdes.c
@@ -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;