Skip to contentSkip to conversation

net: dsa: Mock-up driver couple fixes

PATCH In review Florian Fainelli 2 participants 4 messages Apr 5, 2017 – Apr 6, 2017

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

cover net: dsa: Mock-up driver couple fixes

Thanks to Dan's static checker, a bunch of small issues were found in the code.

Florian Fainelli (2):
net: dsa: loop: Fix uninitialized pvid variable
net: dsa: loop: Initialize err in dsa_loop_vlan_dump

 drivers/net/dsa/dsa_loop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/2 net: dsa: loop: Fix uninitialized pvid variable

Dan's static analyzer reported the following:

	drivers/net/dsa/dsa_loop.c:181 dsa_loop_port_vlan_del()
	error: XXX uninitialized symbol 'pvid'.

we were missing the assignment of pvid to ps->vid, so add that.

Fixes 98cd1552ea27 ("net: dsa: Mock-up driver")
---
 drivers/net/dsa/dsa_loop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/dsa_loop.c +1 -1
index bc5acc15edbf..ee55a902fa66 100644
@@ -164,7 +164,7 @@ static int dsa_loop_port_vlan_del(struct dsa_switch *ds, int port,
 	struct dsa_loop_priv *ps = ds->priv;
 	struct mii_bus *bus = ps->bus;
 	struct dsa_loop_vlan *vl;
-	u16 vid, pvid;
+	u16 vid, pvid = ps->pvid;
 
 	dev_dbg(ds->dev, "%s\n", __func__);
 
Signature · 1 line
2.9.3
#2 lore raw

PATCH 2/2 net: dsa: loop: Initialize err in dsa_loop_vlan_dump

In reply to Florian Fainelli

Dan's static checker reported the following:

	drivers/net/dsa/dsa_loop.c:223 dsa_loop_port_vlan_dump()
	error: uninitialized symbol 'err'.

which could happen if we do hit the continue statement for each iteration of the loop. Initialize err to 0 here.

Fixes 98cd1552ea27 ("net: dsa: Mock-up driver")
---
 drivers/net/dsa/dsa_loop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/dsa_loop.c +1 -1
index ee55a902fa66..f0fc4de4fc9a 100644
@@ -194,7 +194,7 @@ static int dsa_loop_port_vlan_dump(struct dsa_switch *ds, int port,
 	struct mii_bus *bus = ps->bus;
 	struct dsa_loop_vlan *vl;
 	u16 vid, vid_start = 0;
-	int err;
+	int err = 0;
 
 	dev_dbg(ds->dev, "%s\n", __func__);
 
Signature · 1 line
2.9.3