Messages in this thread | | | Date | Fri, 2 Jul 2021 14:57:51 -0300 | From | Arnaldo Carvalho de Melo <> | Subject | Re: [PATCH] perf: tests: fix some mmemory leak issues |
| |
Em Fri, Jul 02, 2021 at 09:56:41PM +0800, Leo Yan escreveu: > 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.
You are right, those buffers are allocated in those functions and then _returned_ via sample->user_stack, the tool (and myself, ugh) got fooled, I'll remove that from my local tree.
Thanks Leo!
- Arnaldo
| |