Skip to content

Commit 9eab0ef

Browse files
Florian Westphalgregkh
authored andcommitted
netfilter: nft_set_pipapo: don't return bogus extension pointer
[ Upstream commit c8a7c2c ] Dan Carpenter says: Commit 17a20e0 ("netfilter: nft_set: remove one argument from lookup and update functions") [..] leads to the following Smatch static checker warning: net/netfilter/nft_set_pipapo_avx2.c:1269 nft_pipapo_avx2_lookup() error: uninitialized symbol 'ext'. Fix this by initing ext to NULL and set it only once we've found a match. Fixes: 17a20e0 ("netfilter: nft_set: remove one argument from lookup and update functions") Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/netfilter-devel/aJBzc3V5wk-yPOnH@stanley.mountain/ Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Stable-dep-of: c4eaca2 ("netfilter: nft_set_pipapo: don't check genbit from packetpath lookups") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 610c1e1 commit 9eab0ef

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

net/netfilter/nft_set_pipapo_avx2.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,12 +1151,12 @@ nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set,
11511151
const u32 *key)
11521152
{
11531153
struct nft_pipapo *priv = nft_set_priv(set);
1154+
const struct nft_set_ext *ext = NULL;
11541155
struct nft_pipapo_scratch *scratch;
11551156
u8 genmask = nft_genmask_cur(net);
11561157
const struct nft_pipapo_match *m;
11571158
const struct nft_pipapo_field *f;
11581159
const u8 *rp = (const u8 *)key;
1159-
const struct nft_set_ext *ext;
11601160
unsigned long *res, *fill;
11611161
bool map_index;
11621162
int i;
@@ -1247,13 +1247,13 @@ nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set,
12471247
goto out;
12481248

12491249
if (last) {
1250-
ext = &f->mt[ret].e->ext;
1251-
if (unlikely(nft_set_elem_expired(ext) ||
1252-
!nft_set_elem_active(ext, genmask))) {
1253-
ext = NULL;
1250+
const struct nft_set_ext *e = &f->mt[ret].e->ext;
1251+
1252+
if (unlikely(nft_set_elem_expired(e) ||
1253+
!nft_set_elem_active(e, genmask)))
12541254
goto next_match;
1255-
}
12561255

1256+
ext = e;
12571257
goto out;
12581258
}
12591259

0 commit comments

Comments
 (0)