lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YZZSLlhHjuDz8sSu@kernel.org>
Date:   Thu, 18 Nov 2021 10:16:30 -0300
From:   Arnaldo Carvalho de Melo <acme@...nel.org>
To:     kajoljain <kjain@...ux.ibm.com>
Cc:     Ian Rogers <irogers@...gle.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
        Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH] perf hist: Fix memory leak of a perf_hpp_fmt

Em Thu, Nov 18, 2021 at 01:28:11PM +0530, kajoljain escreveu:
> 
> 
> On 11/18/21 12:42 PM, Ian Rogers wrote:
> > perf_hpp__column_unregister removes an entry from a list but doesn't
> > free the memory causing a memory leak spotted by leak sanitizer. Add the
> > free while at the same time reducing the scope of the function to
> > static.
> 
> Patch looks good to me.
> 
> Reviewed-by: Kajol Jain<kjain@...ux.ibm.com>

Thanks, applied.

- Arnaldo

 
> Thanks,
> Kajol jain
> 
> > 
> > Signed-off-by: Ian Rogers <irogers@...gle.com>
> > ---
> >  tools/perf/ui/hist.c   | 28 ++++++++++++++--------------
> >  tools/perf/util/hist.h |  1 -
> >  2 files changed, 14 insertions(+), 15 deletions(-)
> > 
> > diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
> > index c1f24d004852..5075ecead5f3 100644
> > --- a/tools/perf/ui/hist.c
> > +++ b/tools/perf/ui/hist.c
> > @@ -535,6 +535,18 @@ struct perf_hpp_list perf_hpp_list = {
> >  #undef __HPP_SORT_ACC_FN
> >  #undef __HPP_SORT_RAW_FN
> >  
> > +static void fmt_free(struct perf_hpp_fmt *fmt)
> > +{
> > +	/*
> > +	 * At this point fmt should be completely
> > +	 * unhooked, if not it's a bug.
> > +	 */
> > +	BUG_ON(!list_empty(&fmt->list));
> > +	BUG_ON(!list_empty(&fmt->sort_list));
> > +
> > +	if (fmt->free)
> > +		fmt->free(fmt);
> > +}
> >  
> >  void perf_hpp__init(void)
> >  {
> > @@ -598,9 +610,10 @@ void perf_hpp_list__prepend_sort_field(struct perf_hpp_list *list,
> >  	list_add(&format->sort_list, &list->sorts);
> >  }
> >  
> > -void perf_hpp__column_unregister(struct perf_hpp_fmt *format)
> > +static void perf_hpp__column_unregister(struct perf_hpp_fmt *format)
> >  {
> >  	list_del_init(&format->list);
> > +	fmt_free(format);
> >  }
> >  
> >  void perf_hpp__cancel_cumulate(void)
> > @@ -672,19 +685,6 @@ void perf_hpp__append_sort_keys(struct perf_hpp_list *list)
> >  }
> >  
> >  
> > -static void fmt_free(struct perf_hpp_fmt *fmt)
> > -{
> > -	/*
> > -	 * At this point fmt should be completely
> > -	 * unhooked, if not it's a bug.
> > -	 */
> > -	BUG_ON(!list_empty(&fmt->list));
> > -	BUG_ON(!list_empty(&fmt->sort_list));
> > -
> > -	if (fmt->free)
> > -		fmt->free(fmt);
> > -}
> > -
> >  void perf_hpp__reset_output_field(struct perf_hpp_list *list)
> >  {
> >  	struct perf_hpp_fmt *fmt, *tmp;
> > diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
> > index 5343b62476e6..621f35ae1efa 100644
> > --- a/tools/perf/util/hist.h
> > +++ b/tools/perf/util/hist.h
> > @@ -369,7 +369,6 @@ enum {
> >  };
> >  
> >  void perf_hpp__init(void);
> > -void perf_hpp__column_unregister(struct perf_hpp_fmt *format);
> >  void perf_hpp__cancel_cumulate(void);
> >  void perf_hpp__setup_output_field(struct perf_hpp_list *list);
> >  void perf_hpp__reset_output_field(struct perf_hpp_list *list);
> > 

-- 

- Arnaldo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ