[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM_iQpVCJ9Hge4c3o-jzwWD+8cryoZFC49wHJH14-r9HYzzRVw@mail.gmail.com>
Date: Mon, 15 Sep 2014 15:15:34 -0700
From: Cong Wang <xiyou.wangcong@...il.com>
To: John Fastabend <john.r.fastabend@...el.com>
Cc: Linux Kernel Network Developers <netdev@...r.kernel.org>,
john fastabend <john.fastabend@...il.com>,
"David S. Miller" <davem@...emloft.net>
Subject: Re: [Patch net-next 2/5] net_sched: fix memory leak in cls_tcindex
On Mon, Sep 15, 2014 at 2:41 PM, John Fastabend
<john.r.fastabend@...el.com> wrote:
> On 09/15/2014 02:06 PM, Cong Wang wrote:
>> Fixes: commit 331b72922c5f58d48fd ("net: sched: RCU cls_tcindex")
>> Cc: John Fastabend <john.fastabend@...il.com>
>> Signed-off-by: Cong Wang <xiyou.wangcong@...il.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;
>
> but you need to set 'err = -ENOMEM' then.
Yeah, I thought err is initialized to ENOMEM.
>
>>
>> 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;
>
> Actually can we just get rid of the balloc here altogether and
> remove the checks in errout_alloc so that cp->perfect and cp->h
> are freed unconditionally? They should be NULL if they are not
> being used because of the kzalloc.
>
Hmm, but for cp->h which you don't duplicate if we free it we
free p->h too, which seems not expected. I think we probably
need to cp->h = kmemdup(p->h) as well.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists