summaryrefslogtreecommitdiff
path: root/net/sched/act_skbedit.c
diff options
context:
space:
mode:
authorDavide Caratti <dcaratti@redhat.com>2019-02-22 14:33:26 +0300
committerDavid S. Miller <davem@davemloft.net>2019-02-25 04:31:43 +0300
commit6191da98062d25276a3b88fb2a94dcbcfb3ea65d (patch)
treeaf18b890509ab7f2d3fc3a9ab75947f51ca409f6 /net/sched/act_skbedit.c
parent8f67c90ee9148eab3d2b4393c3cf76489b27f87c (diff)
downloadlinux-6191da98062d25276a3b88fb2a94dcbcfb3ea65d.tar.xz
net/sched: act_skbedit: fix refcount leak when replace fails
when act_skbedit was converted to use RCU in the data plane, we added an error path, but we forgot to drop the action refcount in case of failure during a 'replace' operation: # tc actions add action skbedit ptype otherhost pass index 100 # tc action show action skbedit total acts 1 action order 0: skbedit ptype otherhost pass index 100 ref 1 bind 0 # tc actions replace action skbedit ptype otherhost drop index 100 RTNETLINK answers: Cannot allocate memory We have an error talking to the kernel # tc action show action skbedit total acts 1 action order 0: skbedit ptype otherhost pass index 100 ref 2 bind 0 Ensure we call tcf_idr_release(), in case 'params_new' allocation failed, also when the action is being replaced. Fixes: c749cdda9089 ("net/sched: act_skbedit: don't use spinlock in the data path") Signed-off-by: Davide Caratti <dcaratti@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/act_skbedit.c')
-rw-r--r--net/sched/act_skbedit.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c
index 64dba3708fce..cfceed28c333 100644
--- a/net/sched/act_skbedit.c
+++ b/net/sched/act_skbedit.c
@@ -189,8 +189,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
params_new = kzalloc(sizeof(*params_new), GFP_KERNEL);
if (unlikely(!params_new)) {
- if (ret == ACT_P_CREATED)
- tcf_idr_release(*a, bind);
+ tcf_idr_release(*a, bind);
return -ENOMEM;
}