Skip to contentSkip to conversation

netfilter: nf_tables: fix error code in nf_tables_updobj()

PATCH In review Dan Carpenter 2 participants 2 messages Feb 24, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: nf_tables: fix error code in nf_tables_updobj()

Set the error code to -ENOMEM instead of leaving it uninitialized.

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

---
This presumably goes through the netfilter tree.

 net/netfilter/nf_tables_api.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/netfilter/nf_tables_api.c +3 -1
index 49060f281342..d0d2339e7c89 100644
@@ -6558,8 +6558,10 @@ static int nf_tables_updobj(const struct nft_ctx *ctx,
 
 	trans = nft_trans_alloc(ctx, NFT_MSG_NEWOBJ,
 				sizeof(struct nft_trans_obj));
-	if (!trans)
+	if (!trans) {
+		err = -ENOMEM;
 		goto err_trans;
+	}
 
 	newobj = nft_obj_init(ctx, type, attr);
 	if (IS_ERR(newobj)) {
Signature · 1 line
2.20.1
maintainer
#1 lore raw
Quoted 4 lines · Dan Carpenter

Set the error code to -ENOMEM instead of leaving it uninitialized.

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

Correct, but this commit no longer exists, it was replaced by dad3bdeef45f81a6e90204bcc85360bb76eccec7,
"netfilter: nf_tables: fix memory leak during stateful obj update"

... which sets err to -ENOMEM.