Netfilter-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] netfilter: nf_tables: Fix an Oops in nf_tables_updobj() error handling
@ 2019-09-06  8:18 Dan Carpenter
  2019-09-06  8:36 ` Fernando Fernandez Mancera
  2019-09-08 16:11 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2019-09-06  8:18 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Fernando Fernandez Mancera
  Cc: Jozsef Kadlecsik, Florian Westphal, netfilter-devel, coreteam,
	kernel-janitors

The "newobj" is an error pointer so we can't pass it to kfree().  It
doesn't need to be freed so we can remove that and I also renamed the
error label.

Fixes: d62d0ba97b58 ("netfilter: nf_tables: Introduce stateful object update operation")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 net/netfilter/nf_tables_api.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index cf767bc58e18..6f66898d63b4 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -5148,7 +5148,7 @@ static int nf_tables_updobj(const struct nft_ctx *ctx,
 	newobj = nft_obj_init(ctx, type, attr);
 	if (IS_ERR(newobj)) {
 		err = PTR_ERR(newobj);
-		goto err1;
+		goto err_free_trans;
 	}
 
 	nft_trans_obj(trans) = obj;
@@ -5157,9 +5157,9 @@ static int nf_tables_updobj(const struct nft_ctx *ctx,
 	list_add_tail(&trans->list, &ctx->net->nft.commit_list);
 
 	return 0;
-err1:
+
+err_free_trans:
 	kfree(trans);
-	kfree(newobj);
 	return err;
 }
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] netfilter: nf_tables: Fix an Oops in nf_tables_updobj() error handling
  2019-09-06  8:18 [PATCH] netfilter: nf_tables: Fix an Oops in nf_tables_updobj() error handling Dan Carpenter
@ 2019-09-06  8:36 ` Fernando Fernandez Mancera
  2019-09-08 16:11 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 3+ messages in thread
From: Fernando Fernandez Mancera @ 2019-09-06  8:36 UTC (permalink / raw)
  To: Dan Carpenter, Pablo Neira Ayuso
  Cc: Jozsef Kadlecsik, Florian Westphal, netfilter-devel, coreteam,
	kernel-janitors

Oh sorry, I missed that. Thanks!

Acked-by: Fernando Fernandez Mancera <ffmancera@riseup.net>

On 9/6/19 10:18 AM, Dan Carpenter wrote:
> The "newobj" is an error pointer so we can't pass it to kfree().  It
> doesn't need to be freed so we can remove that and I also renamed the
> error label.
> 
> Fixes: d62d0ba97b58 ("netfilter: nf_tables: Introduce stateful object update operation")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  net/netfilter/nf_tables_api.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index cf767bc58e18..6f66898d63b4 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -5148,7 +5148,7 @@ static int nf_tables_updobj(const struct nft_ctx *ctx,
>  	newobj = nft_obj_init(ctx, type, attr);
>  	if (IS_ERR(newobj)) {
>  		err = PTR_ERR(newobj);
> -		goto err1;
> +		goto err_free_trans;
>  	}
>  
>  	nft_trans_obj(trans) = obj;
> @@ -5157,9 +5157,9 @@ static int nf_tables_updobj(const struct nft_ctx *ctx,
>  	list_add_tail(&trans->list, &ctx->net->nft.commit_list);
>  
>  	return 0;
> -err1:
> +
> +err_free_trans:
>  	kfree(trans);
> -	kfree(newobj);
>  	return err;
>  }
>  
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] netfilter: nf_tables: Fix an Oops in nf_tables_updobj() error handling
  2019-09-06  8:18 [PATCH] netfilter: nf_tables: Fix an Oops in nf_tables_updobj() error handling Dan Carpenter
  2019-09-06  8:36 ` Fernando Fernandez Mancera
@ 2019-09-08 16:11 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2019-09-08 16:11 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Fernando Fernandez Mancera, Jozsef Kadlecsik, Florian Westphal,
	netfilter-devel, coreteam, kernel-janitors

On Fri, Sep 06, 2019 at 11:18:08AM +0300, Dan Carpenter wrote:
> The "newobj" is an error pointer so we can't pass it to kfree().  It
> doesn't need to be freed so we can remove that and I also renamed the
> error label.

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-06  8:18 [PATCH] netfilter: nf_tables: Fix an Oops in nf_tables_updobj() error handling Dan Carpenter
2019-09-06  8:36 ` Fernando Fernandez Mancera
2019-09-08 16:11 ` Pablo Neira Ayuso

Netfilter-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netfilter-devel/0 netfilter-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netfilter-devel netfilter-devel/ https://lore.kernel.org/netfilter-devel \
		netfilter-devel@vger.kernel.org netfilter-devel@archiver.kernel.org
	public-inbox-index netfilter-devel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netfilter-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox