drivers/net/dsa/sja1105/sja1105_main.c:2342 sja1105_best_effort_vlan_filtering_set() error: uninitialized symbol 'rc'.

From: Dan Carpenter
Date: Mon Aug 31 2020 - 08:37:06 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 4d41ead6ead97c3730bbd186a601a64828668f01
commit: 2cafa72e516f61b6d82c2416b4f5963fb48fd9ce net: dsa: sja1105: add a new best_effort_vlan_filtering devlink parameter
config: arm-randconfig-m031-20200829 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

New smatch warnings:
drivers/net/dsa/sja1105/sja1105_main.c:2342 sja1105_best_effort_vlan_filtering_set() error: uninitialized symbol 'rc'.

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2cafa72e516f61b6d82c2416b4f5963fb48fd9ce
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 2cafa72e516f61b6d82c2416b4f5963fb48fd9ce
vim +/rc +2342 drivers/net/dsa/sja1105/sja1105_main.c

2cafa72e516f61 Vladimir Oltean 2020-05-12 2316 static int sja1105_best_effort_vlan_filtering_set(struct sja1105_private *priv,
2cafa72e516f61 Vladimir Oltean 2020-05-12 2317 bool be_vlan)
2cafa72e516f61 Vladimir Oltean 2020-05-12 2318 {
2cafa72e516f61 Vladimir Oltean 2020-05-12 2319 struct dsa_switch *ds = priv->ds;
2cafa72e516f61 Vladimir Oltean 2020-05-12 2320 bool vlan_filtering;
2cafa72e516f61 Vladimir Oltean 2020-05-12 2321 int port;
2cafa72e516f61 Vladimir Oltean 2020-05-12 2322 int rc;
2cafa72e516f61 Vladimir Oltean 2020-05-12 2323
2cafa72e516f61 Vladimir Oltean 2020-05-12 2324 priv->best_effort_vlan_filtering = be_vlan;
2cafa72e516f61 Vladimir Oltean 2020-05-12 2325
2cafa72e516f61 Vladimir Oltean 2020-05-12 2326 rtnl_lock();
2cafa72e516f61 Vladimir Oltean 2020-05-12 2327 for (port = 0; port < ds->num_ports; port++) {
2cafa72e516f61 Vladimir Oltean 2020-05-12 2328 struct dsa_port *dp;
2cafa72e516f61 Vladimir Oltean 2020-05-12 2329
2cafa72e516f61 Vladimir Oltean 2020-05-12 2330 if (!dsa_is_user_port(ds, port))
2cafa72e516f61 Vladimir Oltean 2020-05-12 2331 continue;

What if ds->num_ports is zero or they're all user ports?

2cafa72e516f61 Vladimir Oltean 2020-05-12 2332
2cafa72e516f61 Vladimir Oltean 2020-05-12 2333 dp = dsa_to_port(ds, port);
2cafa72e516f61 Vladimir Oltean 2020-05-12 2334 vlan_filtering = dsa_port_is_vlan_filtering(dp);
2cafa72e516f61 Vladimir Oltean 2020-05-12 2335
2cafa72e516f61 Vladimir Oltean 2020-05-12 2336 rc = sja1105_vlan_filtering(ds, port, vlan_filtering);
2cafa72e516f61 Vladimir Oltean 2020-05-12 2337 if (rc)
2cafa72e516f61 Vladimir Oltean 2020-05-12 2338 break;
2cafa72e516f61 Vladimir Oltean 2020-05-12 2339 }
2cafa72e516f61 Vladimir Oltean 2020-05-12 2340 rtnl_unlock();
2cafa72e516f61 Vladimir Oltean 2020-05-12 2341
2cafa72e516f61 Vladimir Oltean 2020-05-12 @2342 return rc;
^^^^^^^^^

2cafa72e516f61 Vladimir Oltean 2020-05-12 2343 }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip