Commit 4ea777e4 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[PKT_SCHED]: ipt action: fix module refcount underflow/mem leaks in tcf_ipt_cleanup

Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 55a97ece
......@@ -91,6 +91,25 @@ ipt_destroy_target(struct ipt_entry_target *t)
module_put(t->u.kernel.target->me);
}
static int
tcf_ipt_release(struct tcf_ipt *p, int bind)
{
int ret = 0;
if (p) {
if (bind)
p->bindcnt--;
p->refcnt--;
if (p->bindcnt <= 0 && p->refcnt <= 0) {
ipt_destroy_target(p->t);
kfree(p->tname);
kfree(p->t);
tcf_hash_destroy(p);
ret = ACT_P_DELETED;
}
}
return ret;
}
static int
tcf_ipt_init(struct rtattr *rta, struct rtattr *est, struct tc_action *a,
int ovr, int bind)
......@@ -129,7 +148,7 @@ tcf_ipt_init(struct rtattr *rta, struct rtattr *est, struct tc_action *a,
ret = ACT_P_CREATED;
} else {
if (!ovr) {
tcf_hash_release(p, bind);
tcf_ipt_release(p, bind);
return -EEXIST;
}
}
......@@ -178,15 +197,8 @@ tcf_ipt_init(struct rtattr *rta, struct rtattr *est, struct tc_action *a,
static int
tcf_ipt_cleanup(struct tc_action *a, int bind)
{
struct tcf_ipt *p = PRIV(a,ipt);
if (NULL != p) {
struct ipt_entry_target *t = p->t;
if (t && t->u.kernel.target)
module_put(t->u.kernel.target->me);
return tcf_hash_release(p, bind);
}
return 0;
struct tcf_ipt *p = PRIV(a, ipt);
return tcf_ipt_release(p, bind);
}
static int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment