[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1438682568-8346-12-git-send-email-pablo@netfilter.org>
Date: Tue, 4 Aug 2015 12:02:41 +0200
From: Pablo Neira Ayuso <pablo@...filter.org>
To: netfilter-devel@...r.kernel.org
Cc: davem@...emloft.net, netdev@...r.kernel.org
Subject: [PATCH 11/18] netfilter: Fix memory leak in nf_register_net_hook
From: "Eric W. Biederman" <ebiederm@...ssion.com>
In the rare case that when it is a attempted to use a per network device
netfilter hook and the network device does not exist the newly allocated
structure can leak.
Be a good citizen and free the newly allocated structure in the error
handling code.
Fixes: 085db2c04557 ("netfilter: Per network namespace netfilter hooks.")
Reported-by: kbuild@...org
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@...ssion.com>
Signed-off-by: Pablo Neira Ayuso <pablo@...filter.org>
---
net/netfilter/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index 6896cee..87d237d 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -96,8 +96,10 @@ int nf_register_net_hook(struct net *net, const struct nf_hook_ops *reg)
new->priority = reg->priority;
nf_hook_list = find_nf_hook_list(net, reg);
- if (!nf_hook_list)
+ if (!nf_hook_list) {
+ kfree(new);
return -ENOENT;
+ }
mutex_lock(&nf_hook_mutex);
list_for_each_entry(elem, nf_hook_list, list) {
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists