diff mbox series

[nf] netfilter: nf_tables: make sure err is initialised to sane value

Message ID 20220221210423.28805-1-fw@strlen.de
State Accepted
Delegated to: Pablo Neira
Headers show
Series [nf] netfilter: nf_tables: make sure err is initialised to sane value | expand

Commit Message

Florian Westphal Feb. 21, 2022, 9:04 p.m. UTC
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")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
 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(-)

Comments

Pablo Neira Ayuso Feb. 22, 2022, 7:29 a.m. UTC | #1
On Mon, Feb 21, 2022 at 10:04:23PM +0100, Florian Westphal wrote:
> 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!
diff mbox series

Patch

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 49060f281342..9cd1d7a62804 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -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;