mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Leo Yan <leo.yan@linaro.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: gushengxian <gushengxian507419@gmail.com>,
	will@kernel.org, mathieu.poirier@linaro.org,
	peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com,
	alexander.shishkin@linux.intel.com, jolsa@redhat.com,
	namhyung@kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	gushengxian <gushengxian@yulong.com>
Subject: Re: [PATCH] perf: tests: fix some mmemory leak issues
Date: Fri, 2 Jul 2021 21:56:41 +0800	[thread overview]
Message-ID: <20210702135641.GA22592@leoy-ThinkPad-X240s> (raw)
In-Reply-To: <YN8NjJLHoB+wzLXa@kernel.org>

Hi Arnaldo,

On Fri, Jul 02, 2021 at 09:58:52AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Jul 01, 2021 at 09:09:55PM -0700, gushengxian escreveu:
> > From: gushengxian <gushengxian@yulong.com>
> > 
> > Some memory leak issues should be fixed by free().
> > Reported by cppcheck.

I don't think this patch does the right thing.  You could see that the
memory is allocated in arch specific function sample_ustack(), and the
"buf" pointer is assigned to sample->user_stack.data; and the memory
actually is released in the caller function test_dwarf_unwind__thread:

noinline int test_dwarf_unwind__thread(struct thread *thread)
{
        struct perf_sample sample;
        unsigned long cnt = 0;
        int err = -1;

        memset(&sample, 0, sizeof(sample));

        if (test__arch_unwind_sample(&sample, thread)) {
                pr_debug("failed to get unwind sample\n");
                goto out;
        } 

        [...]

 out:
        zfree(&sample.user_stack.data);
        zfree(&sample.user_regs.regs);
        return err;
}

So this patch will break the testing and doesn't fix any memory leak
issue.

Thanks,
Leo

  reply	other threads:[~2021-07-02 13:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-02  4:09 gushengxian
2021-07-02 12:58 ` Arnaldo Carvalho de Melo
2021-07-02 13:56   ` Leo Yan [this message]
2021-07-02 17:57     ` Arnaldo Carvalho de Melo

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=20210702135641.GA22592@leoy-ThinkPad-X240s \
    --to=leo.yan@linaro.org \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=gushengxian507419@gmail.com \
    --cc=gushengxian@yulong.com \
    --cc=jolsa@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.poirier@linaro.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=will@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

all inboxes | Powered by JetHome®