All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] netfilter: nfnetlink_cthelper: Fix memory leak
@ 2017-03-21  6:57 Jeffy Chen
  2017-03-21 20:14 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Jeffy Chen @ 2017-03-21  6:57 UTC (permalink / raw)
  To: linux-arm-kernel

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

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

* [PATCH] netfilter: nfnetlink_cthelper: Fix memory leak
  2017-03-21  6:57 [PATCH] netfilter: nfnetlink_cthelper: Fix memory leak Jeffy Chen
@ 2017-03-21 20:14 ` Dmitry Torokhov
  2017-03-21 20:35   ` Doug Anderson
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2017-03-21 20:14 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Mar 20, 2017 at 11:57 PM, Jeffy Chen <jeffy.chen@rock-chips.com> wrote:
> We have memory leaks of nf_conntrack_helper & expect_policy.
>
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>

This looks reasonable to me:

Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

But you need to send it to correct lists, and linux-arm-kernel is not it:

./scripts/get_maintainer.pl -f net/netfilter/nfnetlink_cthelper.c
Pablo Neira Ayuso <pablo@netfilter.org> (supporter:NETFILTER)
Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> (supporter:NETFILTER)
"David S. Miller" <davem@davemloft.net> (maintainer:NETWORKING [GENERAL])
netfilter-devel at vger.kernel.org (open list:NETFILTER)
coreteam at netfilter.org (open list:NETFILTER)
netdev at vger.kernel.org (open list:NETWORKING [GENERAL])
linux-kernel at vger.kernel.org (open list)

> ---
>
>  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);
>                 }
>         }
>  }

Thanks.

-- 
Dmitry

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

* [PATCH] netfilter: nfnetlink_cthelper: Fix memory leak
  2017-03-21 20:14 ` Dmitry Torokhov
@ 2017-03-21 20:35   ` Doug Anderson
  0 siblings, 0 replies; 3+ messages in thread
From: Doug Anderson @ 2017-03-21 20:35 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Tue, Mar 21, 2017 at 1:14 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Mon, Mar 20, 2017 at 11:57 PM, Jeffy Chen <jeffy.chen@rock-chips.com> wrote:
>> We have memory leaks of nf_conntrack_helper & expect_policy.
>>
>> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
>
> This looks reasonable to me:
>
> Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>
> But you need to send it to correct lists, and linux-arm-kernel is not it:
>
> ./scripts/get_maintainer.pl -f net/netfilter/nfnetlink_cthelper.c
> Pablo Neira Ayuso <pablo@netfilter.org> (supporter:NETFILTER)
> Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> (supporter:NETFILTER)
> "David S. Miller" <davem@davemloft.net> (maintainer:NETWORKING [GENERAL])
> netfilter-devel at vger.kernel.org (open list:NETFILTER)
> coreteam at netfilter.org (open list:NETFILTER)
> netdev at vger.kernel.org (open list:NETWORKING [GENERAL])
> linux-kernel at vger.kernel.org (open list)

This was picked up and re-posted (with changes) at:

http://marc.info/?l=netfilter-devel&m=149010052628333&w=2

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

end of thread, other threads:[~2017-03-21 20:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-21  6:57 [PATCH] netfilter: nfnetlink_cthelper: Fix memory leak Jeffy Chen
2017-03-21 20:14 ` Dmitry Torokhov
2017-03-21 20:35   ` Doug Anderson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.