Skip to content

Commit c8a7c2c

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: nft_set_pipapo: don't return bogus extension pointer
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>
1 parent 1492e3d commit c8a7c2c

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
@@ -1150,12 +1150,12 @@ nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set,
11501150
const u32 *key)
11511151
{
11521152
struct nft_pipapo *priv = nft_set_priv(set);
1153+
const struct nft_set_ext *ext = NULL;
11531154
struct nft_pipapo_scratch *scratch;
11541155
u8 genmask = nft_genmask_cur(net);
11551156
const struct nft_pipapo_match *m;
11561157
const struct nft_pipapo_field *f;
11571158
const u8 *rp = (const u8 *)key;
1158-
const struct nft_set_ext *ext;
11591159
unsigned long *res, *fill;
11601160
bool map_index;
11611161
int i;
@@ -1246,13 +1246,13 @@ nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set,
12461246
goto out;
12471247

12481248
if (last) {
1249-
ext = &f->mt[ret].e->ext;
1250-
if (unlikely(nft_set_elem_expired(ext) ||
1251-
!nft_set_elem_active(ext, genmask))) {
1252-
ext = NULL;
1249+
const struct nft_set_ext *e = &f->mt[ret].e->ext;
1250+
1251+
if (unlikely(nft_set_elem_expired(e) ||
1252+
!nft_set_elem_active(e, genmask)))
12531253
goto next_match;
1254-
}
12551254

1255+
ext = e;
12561256
goto out;
12571257
}
12581258

0 commit comments

Comments
 (0)