From: Cong Wang <xiyou.wangcong@gmail.com>
To: netdev@vger.kernel.org
Cc: john.fastabend@gmail.com, "David S. Miller" <davem@davemloft.net>,
Cong Wang <xiyou.wangcong@gmail.com>
Subject: [Patch net-next 2/5] net_sched: fix memory leak in cls_tcindex
Date: Mon, 15 Sep 2014 14:06:47 -0700 [thread overview]
Message-ID: <1410815210-6693-3-git-send-email-xiyou.wangcong@gmail.com> (raw)
In-Reply-To: <1410815210-6693-1-git-send-email-xiyou.wangcong@gmail.com>
Fixes: commit 331b72922c5f58d48fd ("net: sched: RCU cls_tcindex")
Cc: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
net/sched/cls_tcindex.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
index a02ca72..16ec1ed 100644
--- a/net/sched/cls_tcindex.c
+++ b/net/sched/cls_tcindex.c
@@ -243,7 +243,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
*/
cp = kzalloc(sizeof(*cp), GFP_KERNEL);
if (!cp)
- return -ENOMEM;
+ goto errout;
cp->mask = p->mask;
cp->shift = p->shift;
@@ -257,6 +257,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
sizeof(*r) * cp->hash, GFP_KERNEL);
if (!cp->perfect)
goto errout;
+ balloc = 1;
}
cp->h = p->h;
@@ -285,9 +286,9 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
if (cp->perfect) {
if (!valid_perfect_hash(cp) ||
cp->hash > cp->alloc_hash)
- goto errout;
+ goto errout_alloc;
} else if (cp->h && cp->hash != cp->alloc_hash) {
- goto errout;
+ goto errout_alloc;
}
err = -EINVAL;
@@ -314,7 +315,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
*/
if (cp->perfect || valid_perfect_hash(cp))
if (handle >= cp->alloc_hash)
- goto errout;
+ goto errout_alloc;
err = -ENOMEM;
@@ -324,7 +325,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
cp->perfect = kcalloc(cp->hash, sizeof(*r), GFP_KERNEL);
if (!cp->perfect)
- goto errout;
+ goto errout_alloc;
for (i = 0; i < cp->hash; i++)
tcf_exts_init(&cp->perfect[i].exts,
TCA_TCINDEX_ACT,
@@ -338,7 +339,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
GFP_KERNEL);
if (!hash)
- goto errout;
+ goto errout_alloc;
cp->h = hash;
balloc = 2;
--
1.8.3.1
next prev parent reply other threads:[~2014-09-15 21:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-15 21:06 [Patch net-next 0/5] net_sched: some fixes and cleanup for tcindex Cong Wang
2014-09-15 21:06 ` [Patch net-next 1/5] net_sched: fix an allocation bug in tcindex_set_parms() Cong Wang
2014-09-15 21:48 ` David Miller
2014-09-15 21:06 ` Cong Wang [this message]
2014-09-15 21:41 ` [Patch net-next 2/5] net_sched: fix memory leak in cls_tcindex John Fastabend
2014-09-15 22:15 ` Cong Wang
2014-09-15 22:46 ` Cong Wang
2014-09-15 21:49 ` David Miller
2014-09-15 21:06 ` [Patch net-next 3/5] net_sched: fix suspicious RCU usage in tcindex_classify() Cong Wang
2014-09-15 21:29 ` John Fastabend
2014-09-15 21:50 ` David Miller
2014-09-15 21:06 ` [Patch net-next 4/5] net_sched: use tcindex_filter_result_init() Cong Wang
2014-09-15 21:51 ` David Miller
2014-09-15 21:06 ` [Patch net-next 5/5] net_sched: clean up tcindex_set_parms() Cong Wang
2014-09-15 21:52 ` David Miller
2014-09-15 22:09 ` John Fastabend
2014-09-15 23:39 ` Cong Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1410815210-6693-3-git-send-email-xiyou.wangcong@gmail.com \
--to=xiyou.wangcong@gmail.com \
--cc=davem@davemloft.net \
--cc=john.fastabend@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).