kernel: act_ctinfo: backport memory leak fix
[openwrt/staging/rmilecki.git] / target / linux / generic / backport-4.19 / 380-v5.3-net-sched-Introduce-act_ctinfo-action.patch
index 8e04dce309229a7dc4d4b571feb884d0baec29c5..a680402f266232ee95919a09c85c16517c793b96 100644 (file)
@@ -1,4 +1,4 @@
-From 6d8071bbbdcd9d3a2fbb49e55b51617906e3b816 Mon Sep 17 00:00:00 2001
+From d129a72f465dab2d9fc8f1580c38600a8b808327 Mon Sep 17 00:00:00 2001
 From: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
 Date: Wed, 13 Mar 2019 20:54:49 +0000
 Subject: [PATCH] net: sched: Backport Introduce act_ctinfo action
@@ -112,9 +112,9 @@ Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
  include/uapi/linux/tc_act/tc_ctinfo.h     |  29 ++
  net/sched/Kconfig                         |  17 +
  net/sched/Makefile                        |   1 +
- net/sched/act_ctinfo.c                    | 409 ++++++++++++++++++++++
+ net/sched/act_ctinfo.c                    | 420 ++++++++++++++++++++++
  tools/testing/selftests/tc-testing/config |   1 +
- 7 files changed, 492 insertions(+), 1 deletion(-)
+ 7 files changed, 503 insertions(+), 1 deletion(-)
  create mode 100644 include/net/tc_act/tc_ctinfo.h
  create mode 100644 include/uapi/linux/tc_act/tc_ctinfo.h
  create mode 100644 net/sched/act_ctinfo.c
@@ -237,7 +237,7 @@ Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
  obj-$(CONFIG_NET_IFE_SKBMARK) += act_meta_mark.o
 --- /dev/null
 +++ b/net/sched/act_ctinfo.c
-@@ -0,0 +1,409 @@
+@@ -0,0 +1,420 @@
 +// SPDX-License-Identifier: GPL-2.0+
 +/* net/sched/act_ctinfo.c  netfilter ctinfo connmark actions
 + *
@@ -601,6 +601,16 @@ Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
 +      return tcf_idr_search(tn, a, index);
 +}
 +
++static void tcf_ctinfo_cleanup(struct tc_action *a)
++{
++      struct tcf_ctinfo *ci = to_ctinfo(a);
++      struct tcf_ctinfo_params *cp;
++
++      cp = rcu_dereference_protected(ci->params, 1);
++      if (cp)
++              kfree_rcu(cp, rcu);
++}
++
 +static struct tc_action_ops act_ctinfo_ops = {
 +      .kind   = "ctinfo",
 +      .type   = TCA_ID_CTINFO,
@@ -609,6 +619,7 @@ Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
 +      .dump   = tcf_ctinfo_dump,
 +      .init   = tcf_ctinfo_init,
 +      .walk   = tcf_ctinfo_walker,
++      .cleanup= tcf_ctinfo_cleanup,
 +      .lookup = tcf_ctinfo_search,
 +      .size   = sizeof(struct tcf_ctinfo),
 +};