netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: gfree.wind@foxmail.com
To: pablo@netfilter.org, netfilter-devel@vger.kernel.org
Cc: Gao Feng <fgao@ikuai8.com>
Subject: [PATCH nf v2 1/1] netfilter: xt_CT: Fix one possible memleak of timeout
Date: Thu,  6 Apr 2017 19:19:34 +0800	[thread overview]
Message-ID: <1491477574-82700-1-git-send-email-gfree.wind@foxmail.com> (raw)

From: Gao Feng <fgao@ikuai8.com>

When nf_ct_timeout_ext_add failed in xt_ct_set_timeout, it should
free the timeout refcnt.

Now goto the err_put_timeout error handler instead of going ahead.

Signed-off-by: Gao Feng <fgao@ikuai8.com>
---
 v2: Keep the ret = -ENOMEM, per Gao Feng
 v1: initial version

 net/netfilter/xt_CT.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/xt_CT.c b/net/netfilter/xt_CT.c
index b008db0..a1783b6 100644
--- a/net/netfilter/xt_CT.c
+++ b/net/netfilter/xt_CT.c
@@ -167,8 +167,10 @@ static void __xt_ct_tg_timeout_put(struct ctnl_timeout *timeout)
 		goto err_put_timeout;
 	}
 	timeout_ext = nf_ct_timeout_ext_add(ct, timeout, GFP_ATOMIC);
-	if (timeout_ext == NULL)
+	if (!timeout_ext) {
 		ret = -ENOMEM;
+		goto err_put_timeout;
+	}
 
 	rcu_read_unlock();
 	return ret;
-- 
1.9.1





             reply	other threads:[~2017-04-06 11:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-06 11:19 gfree.wind [this message]
2017-04-13 22:24 ` [PATCH nf v2 1/1] netfilter: xt_CT: Fix one possible memleak of timeout Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1491477574-82700-1-git-send-email-gfree.wind@foxmail.com \
    --to=gfree.wind@foxmail.com \
    --cc=fgao@ikuai8.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).