Skip to contentSkip to conversation

net/ipv4/fib_trie.c:1575 fib_table_lookup() error: uninitialized symbol 'nhsel'.

PATCH New Dan Carpenter 1 participant 1 message May 23, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 4/7 net/ipv4/fib_trie.c:1575 fib_table_lookup() error: uninitialized symbol 'nhsel'.

tree:   https://github.com/dsahern/linux nexthops/del-group-03
head:   b8c06bc47e0a04603de20861b8d5f7291ff0bc12
commit: 063512a047f24cd25298dbb37ae1247a407dbdde [4/7] ipv4: Refactor nhc evaluation in fib_table_lookup

:::::: branch date: 19 hours ago
:::::: commit date: 20 hours ago
config: x86_64-defconfig (attached as .config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build):

        git checkout 063512a047f24cd25298dbb37ae1247a407dbdde
        # save the attached .config to linux build tree
        make ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate

New smatch warnings:
net/ipv4/fib_trie.c:1575 fib_table_lookup() error: uninitialized symbol 'nhsel'.

# https://github.com/dsahern/linux/commit/063512a047f24cd25298dbb37ae1247a407dbdde
git remote add dsahern-linux https://github.com/dsahern/linux
git remote update dsahern-linux
git checkout 063512a047f24cd25298dbb37ae1247a407dbdde
vim +/nhsel +1575 net/ipv4/fib_trie.c

19baf839ff4a8d Robert Olsson     2005-06-21  1519  found:
71e8b67d0fdd2f Alexander Duyck   2015-03-04  1520  	/* this line carries forward the xor from earlier in the function */
71e8b67d0fdd2f Alexander Duyck   2015-03-04  1521  	index = key ^ n->key;
71e8b67d0fdd2f Alexander Duyck   2015-03-04  1522  
9f9e636d4f89f7 Alexander Duyck   2014-12-31  1523  	/* Step 3: Process the leaf, if that fails fall back to backtracing */
79e5ad2ceb0067 Alexander Duyck   2015-02-25  1524  	hlist_for_each_entry_rcu(fa, &n->leaf, fa_list) {
345e9b54268ae0 Alexander Duyck   2014-12-31  1525  		struct fib_info *fi = fa->fa_info;
063512a047f24c David Ahern       2020-05-21  1526  		struct fib_nh_common *nhc;
345e9b54268ae0 Alexander Duyck   2014-12-31  1527  		int nhsel, err;
                                                                    ^^^^^
345e9b54268ae0 Alexander Duyck   2014-12-31  1528  
a5829f536b3d11 Alexander Duyck   2016-01-28  1529  		if ((BITS_PER_LONG > KEYLENGTH) || (fa->fa_slen < KEYLENGTH)) {
a5829f536b3d11 Alexander Duyck   2016-01-28  1530  			if (index >= (1ul << fa->fa_slen))
9b6ebad5c3a152 Alexander Duyck   2015-02-25  1531  				continue;
a5829f536b3d11 Alexander Duyck   2016-01-28  1532  		}
345e9b54268ae0 Alexander Duyck   2014-12-31  1533  		if (fa->fa_tos && fa->fa_tos != flp->flowi4_tos)
345e9b54268ae0 Alexander Duyck   2014-12-31  1534  			continue;
345e9b54268ae0 Alexander Duyck   2014-12-31  1535  		if (fi->fib_dead)
345e9b54268ae0 Alexander Duyck   2014-12-31  1536  			continue;
345e9b54268ae0 Alexander Duyck   2014-12-31  1537  		if (fa->fa_info->fib_scope < flp->flowi4_scope)
345e9b54268ae0 Alexander Duyck   2014-12-31  1538  			continue;
345e9b54268ae0 Alexander Duyck   2014-12-31  1539  		fib_alias_accessed(fa);
345e9b54268ae0 Alexander Duyck   2014-12-31  1540  		err = fib_props[fa->fa_type].error;
345e9b54268ae0 Alexander Duyck   2014-12-31  1541  		if (unlikely(err < 0)) {
4c7e8084fd467d David Ahern       2019-06-03  1542  out_reject:
345e9b54268ae0 Alexander Duyck   2014-12-31  1543  #ifdef CONFIG_IP_FIB_TRIE_STATS
345e9b54268ae0 Alexander Duyck   2014-12-31  1544  			this_cpu_inc(stats->semantic_match_passed);
345e9b54268ae0 Alexander Duyck   2014-12-31  1545  #endif
9f323973c915d4 David Ahern       2018-05-23  1546  			trace_fib_table_lookup(tb->tb_id, flp, NULL, err);
345e9b54268ae0 Alexander Duyck   2014-12-31  1547  			return err;
345e9b54268ae0 Alexander Duyck   2014-12-31  1548  		}
345e9b54268ae0 Alexander Duyck   2014-12-31  1549  		if (fi->fib_flags & RTNH_F_DEAD)
345e9b54268ae0 Alexander Duyck   2014-12-31  1550  			continue;
4c7e8084fd467d David Ahern       2019-06-03  1551  
063512a047f24c David Ahern       2020-05-21  1552  		if (unlikely(fi->nh)) {
063512a047f24c David Ahern       2020-05-21  1553  			if (nexthop_is_blackhole(fi->nh)) {
4c7e8084fd467d David Ahern       2019-06-03  1554  				err = fib_props[RTN_BLACKHOLE].error;
4c7e8084fd467d David Ahern       2019-06-03  1555  				goto out_reject;
4c7e8084fd467d David Ahern       2019-06-03  1556  			}
4c7e8084fd467d David Ahern       2019-06-03  1557  
063512a047f24c David Ahern       2020-05-21  1558  			nhc = nexthop_get_nhc_lookup(fi->nh, fib_flags, flp);
063512a047f24c David Ahern       2020-05-21  1559  			if (nhc)
063512a047f24c David Ahern       2020-05-21  1560  				goto set_result;
                                                                                ^^^^^^^^^^^^^^^

goto

063512a047f24c David Ahern       2020-05-21  1561  			goto miss;
063512a047f24c David Ahern       2020-05-21  1562  		}
063512a047f24c David Ahern       2020-05-21  1563  
5481d73f81549e David Ahern       2019-06-03  1564  		for (nhsel = 0; nhsel < fib_info_num_path(fi); nhsel++) {
063512a047f24c David Ahern       2020-05-21  1565  			nhc = fib_info_nhc(fi, nhsel);
345e9b54268ae0 Alexander Duyck   2014-12-31  1566  
063512a047f24c David Ahern       2020-05-21  1567  			if (!fib_lookup_good_nhc(nhc, fib_flags, flp))
345e9b54268ae0 Alexander Duyck   2014-12-31  1568  				continue;
063512a047f24c David Ahern       2020-05-21  1569  set_result:
345e9b54268ae0 Alexander Duyck   2014-12-31  1570  			if (!(fib_flags & FIB_LOOKUP_NOREF))
0029c0deb590bc Reshetova, Elena  2017-07-04  1571  				refcount_inc(&fi->fib_clntref);
345e9b54268ae0 Alexander Duyck   2014-12-31  1572  
6ffd903415320d David Ahern       2017-05-25  1573  			res->prefix = htonl(n->key);
9b6ebad5c3a152 Alexander Duyck   2015-02-25  1574  			res->prefixlen = KEYLENGTH - fa->fa_slen;
345e9b54268ae0 Alexander Duyck   2014-12-31 @1575  			res->nh_sel = nhsel;
                                                                        ^^^^^^^^^^^^^^^^^^^

Uninitialized.

eba618abacade7 David Ahern       2019-04-02  1576  			res->nhc = nhc;
345e9b54268ae0 Alexander Duyck   2014-12-31  1577  			res->type = fa->fa_type;
345e9b54268ae0 Alexander Duyck   2014-12-31  1578  			res->scope = fi->fib_scope;
345e9b54268ae0 Alexander Duyck   2014-12-31  1579  			res->fi = fi;
345e9b54268ae0 Alexander Duyck   2014-12-31  1580  			res->table = tb;
79e5ad2ceb0067 Alexander Duyck   2015-02-25  1581  			res->fa_head = &n->leaf;
345e9b54268ae0 Alexander Duyck   2014-12-31  1582  #ifdef CONFIG_IP_FIB_TRIE_STATS
345e9b54268ae0 Alexander Duyck   2014-12-31  1583  			this_cpu_inc(stats->semantic_match_passed);
345e9b54268ae0 Alexander Duyck   2014-12-31  1584  #endif
eba618abacade7 David Ahern       2019-04-02  1585  			trace_fib_table_lookup(tb->tb_id, flp, nhc, err);
f6d3c19274c74f David Ahern       2015-08-28  1586  
345e9b54268ae0 Alexander Duyck   2014-12-31  1587  			return err;
345e9b54268ae0 Alexander Duyck   2014-12-31  1588  		}
345e9b54268ae0 Alexander Duyck   2014-12-31  1589  	}
063512a047f24c David Ahern       2020-05-21  1590  miss:
345e9b54268ae0 Alexander Duyck   2014-12-31  1591  #ifdef CONFIG_IP_FIB_TRIE_STATS
345e9b54268ae0 Alexander Duyck   2014-12-31  1592  	this_cpu_inc(stats->semantic_match_miss);
345e9b54268ae0 Alexander Duyck   2014-12-31  1593  #endif
9f9e636d4f89f7 Alexander Duyck   2014-12-31  1594  	goto backtrace;
19baf839ff4a8d Robert Olsson     2005-06-21  1595  }
6fc01438a94702 Florian Westphal  2011-08-25  1596  EXPORT_SYMBOL_GPL(fib_table_lookup);

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