Skip to contentSkip to conversation

netfilter: nf_tables: make sure err is initialised to sane value

PATCH In review Florian Westphal 2 participants 2 messages Feb 21, 2022 – Feb 22, 2022

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: nf_tables: make sure err is initialised to sane value

All warnings (new ones prefixed by >>):

net/netfilter/nf_tables_api.c:6561:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true

Fixes 33170d18fd2c ("netfilter: nf_tables: fix memory leak during stateful obj update")

---
For some reason gcc 11.2 doesn't emit such a warning.

 net/netfilter/nf_tables_api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +1 -1
index 49060f281342..9cd1d7a62804 100644
@@ -6551,7 +6551,7 @@ static int nf_tables_updobj(const struct nft_ctx *ctx,
 {
 	struct nft_object *newobj;
 	struct nft_trans *trans;
-	int err;
+	int err = -ENOMEM;
 
 	if (!try_module_get(type->owner))
 		return -ENOENT;
Signature · 1 line
2.34.1
#1 lore raw
Quoted 3 lines · Florian Westphal

All warnings (new ones prefixed by >>):

net/netfilter/nf_tables_api.c:6561:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true

I have collapsed this to the original patch, thanks!