netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: Linux Kernel Network Developers <netdev@vger.kernel.org>,
	Thomas Graf <tgraf@suug.ch>, Jamal Hadi Salim <jhs@mojatatu.com>
Subject: Re: [Patch net] cls_cgroup: fix memory leak in cls_cgroup_change()
Date: Mon, 6 Jan 2014 15:23:09 -0800	[thread overview]
Message-ID: <CAM_iQpU8rvceS7tAgv6DacHvaxJFBFDJSFhhBhWV-wqJ+A_xOA@mail.gmail.com> (raw)
In-Reply-To: <20140103.210209.901517258686201934.davem@davemloft.net>

On Fri, Jan 3, 2014 at 6:02 PM, David Miller <davem@davemloft.net> wrote:
> From: Cong Wang <xiyou.wangcong@gmail.com>
> Date: Fri,  3 Jan 2014 11:13:19 -0800
>
>> Fix it by moving allocation to ->init().
>>
>> Cc: Thomas Graf <tgraf@suug.ch>
>> Cc: David S. Miller <davem@davemloft.net>
>> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
>> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
>
> I don't understand how the memory leak can happen, please explain
> it in your commit message.
>

The leak happens when ->change() fails after the allocation
inside  cls_cgroup_change(), its caller only does cleanup
when itself creates one. So, the callee should do cleanup
on error path by itself. But I may miss something.

Since it is not urgent at all, I will explain this in changelog
and resend it for net-next.

> Also:
>
>>  {
>> +     struct cls_cgroup_head *head;
>> +     head = kzalloc(sizeof(*head), GFP_KERNEL);
>
> Please add an empty line between local variable declarations
> and code.
>

OK.

  reply	other threads:[~2014-01-06 23:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-03 19:13 [Patch net] cls_cgroup: fix memory leak in cls_cgroup_change() Cong Wang
2014-01-04  2:02 ` David Miller
2014-01-06 23:23   ` Cong Wang [this message]
2014-01-07 21:19     ` Thomas Graf

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=CAM_iQpU8rvceS7tAgv6DacHvaxJFBFDJSFhhBhWV-wqJ+A_xOA@mail.gmail.com \
    --to=xiyou.wangcong@gmail.com \
    --cc=davem@davemloft.net \
    --cc=jhs@mojatatu.com \
    --cc=netdev@vger.kernel.org \
    --cc=tgraf@suug.ch \
    /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).