public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Shaochun Chen <cscnull@gmail.com>
Cc: pablo@netfilter.org, kadlec@blackhole.kfki.hu, fw@strlen.de,
	davem@davemloft.net, johannes.berg@intel.com,
	pombredanne@nexb.com, kstewart@linuxfoundation.org,
	gregkh@linuxfoundation.org, Jason@zx2c4.com, dsahern@gmail.com,
	lucien.xin@gmail.com, ktkhai@virtuozzo.com,
	xiyou.wangcong@gmail.com, linux-kernel@vger.kernel.org,
	netfilter-devel@vger.kernel.org, netdev@vger.kernel.org,
	tom@quantonium.net
Subject: Re: [PATCH] netlink: fix memory leak
Date: Sun, 22 Jul 2018 11:02:34 +0200	[thread overview]
Message-ID: <20180722090234.bttpk2xmwf4d7hfo@breakpoint.cc> (raw)
In-Reply-To: <20180722024925.3176-1-cscnull@gmail.com>

Shaochun Chen <cscnull@gmail.com> wrote:

[ CC Tom Herbert ]

> and the memory which pointed by control->data will leak. so if netlink_dump
> start fail, call control->done to free the memory.

Tom, I was about to suggest moving extra allocations for dumps
into a ->start() callback whereever possible.

However, it looks like ->done() is not guaranteed to be called even if
->start() was invoked, but it seems at least ila assumes ->done always
cleans up after ->start.

I am looking at netlink_dump(); it calls ->done() only after the dump
callback was invoked.

In nf_tables_api.c case it might be possible to defer allocations until
->dump() is called for first time via cb_args but I don't think its
going to be any better than cleaning up manually after netlink_dump_start()
returned an error.

Any better ideas or advice on how to procceed?

Thanks!

      parent reply	other threads:[~2018-07-22  9:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-22  2:49 [PATCH] netlink: fix memory leak Shaochun Chen
2018-07-22  5:00 ` Jason A. Donenfeld
2018-07-22  8:12   ` Florian Westphal
2018-07-22  9:02 ` Florian Westphal [this message]

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=20180722090234.bttpk2xmwf4d7hfo@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=Jason@zx2c4.com \
    --cc=cscnull@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=johannes.berg@intel.com \
    --cc=kadlec@blackhole.kfki.hu \
    --cc=kstewart@linuxfoundation.org \
    --cc=ktkhai@virtuozzo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucien.xin@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=pombredanne@nexb.com \
    --cc=tom@quantonium.net \
    --cc=xiyou.wangcong@gmail.com \
    /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