linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: jeffy.chen@rock-chips.com (Jeffy Chen)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] netfilter: nfnetlink_cthelper: Fix memory leak
Date: Tue, 21 Mar 2017 14:57:05 +0800	[thread overview]
Message-ID: <1490079425-6172-1-git-send-email-jeffy.chen@rock-chips.com> (raw)

We have memory leaks of nf_conntrack_helper & expect_policy.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---

 net/netfilter/nfnetlink_cthelper.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/netfilter/nfnetlink_cthelper.c b/net/netfilter/nfnetlink_cthelper.c
index de87823..99d4bd7 100644
--- a/net/netfilter/nfnetlink_cthelper.c
+++ b/net/netfilter/nfnetlink_cthelper.c
@@ -191,6 +191,8 @@ nfnl_cthelper_parse_expect_policy(struct nf_conntrack_helper *helper,
 		if (ret < 0)
 			goto err;
 	}
+
+	kfree(helper->expect_policy);
 	helper->expect_policy = expect_policy;
 	return 0;
 err:
@@ -249,6 +251,7 @@ nfnl_cthelper_create(const struct nlattr * const tb[],
 
 	return 0;
 err:
+	kfree(helper->expect_policy);
 	kfree(helper);
 	return ret;
 }
@@ -612,6 +615,8 @@ static int nfnl_cthelper_del(struct net *net, struct sock *nfnl,
 
 			found = true;
 			nf_conntrack_helper_unregister(cur);
+			kfree(cur->expect_policy);
+			kfree(cur);
 		}
 	}
 	/* Make sure we return success if we flush and there is no helpers */
@@ -675,6 +680,8 @@ static void __exit nfnl_cthelper_exit(void)
 				continue;
 
 			nf_conntrack_helper_unregister(cur);
+			kfree(cur->expect_policy);
+			kfree(cur);
 		}
 	}
 }
-- 
2.1.4

             reply	other threads:[~2017-03-21  6:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-21  6:57 Jeffy Chen [this message]
2017-03-21 20:14 ` [PATCH] netfilter: nfnetlink_cthelper: Fix memory leak Dmitry Torokhov
2017-03-21 20:35   ` Doug Anderson

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=1490079425-6172-1-git-send-email-jeffy.chen@rock-chips.com \
    --to=jeffy.chen@rock-chips.com \
    --cc=linux-arm-kernel@lists.infradead.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).