[v1,00/11] perf: Fix errors detected by Smatch
mbox series

Message ID 20190702103420.27540-1-leo.yan@linaro.org
Headers show
Series
  • perf: Fix errors detected by Smatch
Related show

Message

Leo Yan July 2, 2019, 10:34 a.m. UTC
When I used static checker Smatch for perf building, the main target is
to check if there have any potential issues in Arm cs-etm code.  So
finally I get many reporting for errors/warnings.

I used below command for using static checker with perf building:

  # make VF=1 CORESIGHT=1 -C tools/perf/ \
    CHECK="/root/Work/smatch/smatch --full-path" \
    CC=/root/Work/smatch/cgcc | tee smatch_reports.txt

I reviewed the errors one by one, if I understood some of these errors
so changed the code as I can, this patch set is the working result; but
still leave some errors due to I don't know what's the best way to fix
it.  There also have many inconsistent indenting warnings.  So I firstly
send out this patch set and let's see what's the feedback from public
reviewing.

Leo Yan (11):
  perf report: Smatch: Fix potential NULL pointer dereference
  perf stat: Smatch: Fix use-after-freed pointer
  perf top: Smatch: Fix potential NULL pointer dereference
  perf annotate: Smatch: Fix dereferencing freed memory
  perf trace: Smatch: Fix potential NULL pointer dereference
  perf hists: Smatch: Fix potential NULL pointer dereference
  perf map: Smatch: Fix potential NULL pointer dereference
  perf session: Smatch: Fix potential NULL pointer dereference
  perf intel-bts: Smatch: Fix potential NULL pointer dereference
  perf intel-pt: Smatch: Fix potential NULL pointer dereference
  perf cs-etm: Smatch: Fix potential NULL pointer dereference

 tools/perf/builtin-report.c    |  4 ++--
 tools/perf/builtin-stat.c      |  2 +-
 tools/perf/builtin-top.c       |  8 ++++++--
 tools/perf/builtin-trace.c     |  5 +++--
 tools/perf/ui/browsers/hists.c | 13 +++++++++----
 tools/perf/util/annotate.c     |  6 ++----
 tools/perf/util/cs-etm.c       |  2 +-
 tools/perf/util/intel-bts.c    |  5 ++---
 tools/perf/util/intel-pt.c     |  5 ++---
 tools/perf/util/map.c          |  7 +++++--
 tools/perf/util/session.c      |  3 +++
 11 files changed, 36 insertions(+), 24 deletions(-)

Comments

Jiri Olsa July 2, 2019, 11:07 a.m. UTC | #1
On Tue, Jul 02, 2019 at 06:34:09PM +0800, Leo Yan wrote:
> When I used static checker Smatch for perf building, the main target is
> to check if there have any potential issues in Arm cs-etm code.  So
> finally I get many reporting for errors/warnings.
> 
> I used below command for using static checker with perf building:
> 
>   # make VF=1 CORESIGHT=1 -C tools/perf/ \
>     CHECK="/root/Work/smatch/smatch --full-path" \
>     CC=/root/Work/smatch/cgcc | tee smatch_reports.txt
> 
> I reviewed the errors one by one, if I understood some of these errors
> so changed the code as I can, this patch set is the working result; but
> still leave some errors due to I don't know what's the best way to fix
> it.  There also have many inconsistent indenting warnings.  So I firstly
> send out this patch set and let's see what's the feedback from public
> reviewing.
> 
> Leo Yan (11):
>   perf report: Smatch: Fix potential NULL pointer dereference
>   perf stat: Smatch: Fix use-after-freed pointer
>   perf top: Smatch: Fix potential NULL pointer dereference
>   perf annotate: Smatch: Fix dereferencing freed memory
>   perf trace: Smatch: Fix potential NULL pointer dereference
>   perf hists: Smatch: Fix potential NULL pointer dereference
>   perf map: Smatch: Fix potential NULL pointer dereference
>   perf session: Smatch: Fix potential NULL pointer dereference
>   perf intel-bts: Smatch: Fix potential NULL pointer dereference
>   perf intel-pt: Smatch: Fix potential NULL pointer dereference
>   perf cs-etm: Smatch: Fix potential NULL pointer dereference

from quick look it all looks good to me, nice tool ;-)

Acked-by: Jiri Olsa <jolsa@kernel.org>

jirka

> 
>  tools/perf/builtin-report.c    |  4 ++--
>  tools/perf/builtin-stat.c      |  2 +-
>  tools/perf/builtin-top.c       |  8 ++++++--
>  tools/perf/builtin-trace.c     |  5 +++--
>  tools/perf/ui/browsers/hists.c | 13 +++++++++----
>  tools/perf/util/annotate.c     |  6 ++----
>  tools/perf/util/cs-etm.c       |  2 +-
>  tools/perf/util/intel-bts.c    |  5 ++---
>  tools/perf/util/intel-pt.c     |  5 ++---
>  tools/perf/util/map.c          |  7 +++++--
>  tools/perf/util/session.c      |  3 +++
>  11 files changed, 36 insertions(+), 24 deletions(-)
> 
> -- 
> 2.17.1
>
Leo Yan July 3, 2019, 1:48 a.m. UTC | #2
On Tue, Jul 02, 2019 at 01:07:43PM +0200, Jiri Olsa wrote:
> On Tue, Jul 02, 2019 at 06:34:09PM +0800, Leo Yan wrote:
> > When I used static checker Smatch for perf building, the main target is
> > to check if there have any potential issues in Arm cs-etm code.  So
> > finally I get many reporting for errors/warnings.
> > 
> > I used below command for using static checker with perf building:
> > 
> >   # make VF=1 CORESIGHT=1 -C tools/perf/ \
> >     CHECK="/root/Work/smatch/smatch --full-path" \
> >     CC=/root/Work/smatch/cgcc | tee smatch_reports.txt
> > 
> > I reviewed the errors one by one, if I understood some of these errors
> > so changed the code as I can, this patch set is the working result; but
> > still leave some errors due to I don't know what's the best way to fix
> > it.  There also have many inconsistent indenting warnings.  So I firstly
> > send out this patch set and let's see what's the feedback from public
> > reviewing.
> > 
> > Leo Yan (11):
> >   perf report: Smatch: Fix potential NULL pointer dereference
> >   perf stat: Smatch: Fix use-after-freed pointer
> >   perf top: Smatch: Fix potential NULL pointer dereference
> >   perf annotate: Smatch: Fix dereferencing freed memory
> >   perf trace: Smatch: Fix potential NULL pointer dereference
> >   perf hists: Smatch: Fix potential NULL pointer dereference
> >   perf map: Smatch: Fix potential NULL pointer dereference
> >   perf session: Smatch: Fix potential NULL pointer dereference
> >   perf intel-bts: Smatch: Fix potential NULL pointer dereference
> >   perf intel-pt: Smatch: Fix potential NULL pointer dereference
> >   perf cs-etm: Smatch: Fix potential NULL pointer dereference
> 
> from quick look it all looks good to me, nice tool ;-)
> 
> Acked-by: Jiri Olsa <jolsa@kernel.org>

Thanks for reviewing, Jiri.

@Arnaldo, Just want to check, will you firstly pick up 01~05, 07,
08/11 patches if you think they are okay?  Or you want to wait me to
spin new patch set with all patches after I gather all comments?

Thanks,
Leo Yan

> >  tools/perf/builtin-report.c    |  4 ++--
> >  tools/perf/builtin-stat.c      |  2 +-
> >  tools/perf/builtin-top.c       |  8 ++++++--
> >  tools/perf/builtin-trace.c     |  5 +++--
> >  tools/perf/ui/browsers/hists.c | 13 +++++++++----
> >  tools/perf/util/annotate.c     |  6 ++----
> >  tools/perf/util/cs-etm.c       |  2 +-
> >  tools/perf/util/intel-bts.c    |  5 ++---
> >  tools/perf/util/intel-pt.c     |  5 ++---
> >  tools/perf/util/map.c          |  7 +++++--
> >  tools/perf/util/session.c      |  3 +++
> >  11 files changed, 36 insertions(+), 24 deletions(-)
> > 
> > -- 
> > 2.17.1
> >
Arnaldo Carvalho de Melo July 3, 2019, 6:18 p.m. UTC | #3
Em Wed, Jul 03, 2019 at 09:48:08AM +0800, Leo Yan escreveu:
> On Tue, Jul 02, 2019 at 01:07:43PM +0200, Jiri Olsa wrote:
> > On Tue, Jul 02, 2019 at 06:34:09PM +0800, Leo Yan wrote:
> > > When I used static checker Smatch for perf building, the main target is
> > > to check if there have any potential issues in Arm cs-etm code.  So
> > > finally I get many reporting for errors/warnings.
> > > 
> > > I used below command for using static checker with perf building:
> > > 
> > >   # make VF=1 CORESIGHT=1 -C tools/perf/ \
> > >     CHECK="/root/Work/smatch/smatch --full-path" \
> > >     CC=/root/Work/smatch/cgcc | tee smatch_reports.txt
> > > 
> > > I reviewed the errors one by one, if I understood some of these errors
> > > so changed the code as I can, this patch set is the working result; but
> > > still leave some errors due to I don't know what's the best way to fix
> > > it.  There also have many inconsistent indenting warnings.  So I firstly
> > > send out this patch set and let's see what's the feedback from public
> > > reviewing.
> > > 
> > > Leo Yan (11):
> > >   perf report: Smatch: Fix potential NULL pointer dereference
> > >   perf stat: Smatch: Fix use-after-freed pointer
> > >   perf top: Smatch: Fix potential NULL pointer dereference
> > >   perf annotate: Smatch: Fix dereferencing freed memory
> > >   perf trace: Smatch: Fix potential NULL pointer dereference
> > >   perf hists: Smatch: Fix potential NULL pointer dereference
> > >   perf map: Smatch: Fix potential NULL pointer dereference
> > >   perf session: Smatch: Fix potential NULL pointer dereference
> > >   perf intel-bts: Smatch: Fix potential NULL pointer dereference
> > >   perf intel-pt: Smatch: Fix potential NULL pointer dereference
> > >   perf cs-etm: Smatch: Fix potential NULL pointer dereference
> > 
> > from quick look it all looks good to me, nice tool ;-)
> > 
> > Acked-by: Jiri Olsa <jolsa@kernel.org>
> 
> Thanks for reviewing, Jiri.
> 
> @Arnaldo, Just want to check, will you firstly pick up 01~05, 07,
> 08/11 patches if you think they are okay?  Or you want to wait me to
> spin new patch set with all patches after I gather all comments?

I'm picking up the uncontrovertial, will push to my perf/core branch,
continue from there, please.

- Arnaldo
 
> Thanks,
> Leo Yan
> 
> > >  tools/perf/builtin-report.c    |  4 ++--
> > >  tools/perf/builtin-stat.c      |  2 +-
> > >  tools/perf/builtin-top.c       |  8 ++++++--
> > >  tools/perf/builtin-trace.c     |  5 +++--
> > >  tools/perf/ui/browsers/hists.c | 13 +++++++++----
> > >  tools/perf/util/annotate.c     |  6 ++----
> > >  tools/perf/util/cs-etm.c       |  2 +-
> > >  tools/perf/util/intel-bts.c    |  5 ++---
> > >  tools/perf/util/intel-pt.c     |  5 ++---
> > >  tools/perf/util/map.c          |  7 +++++--
> > >  tools/perf/util/session.c      |  3 +++
> > >  11 files changed, 36 insertions(+), 24 deletions(-)
> > > 
> > > -- 
> > > 2.17.1
> > >
Leo Yan July 4, 2019, 7:29 a.m. UTC | #4
Hi Arnaldo,

On Wed, Jul 03, 2019 at 03:18:15PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Jul 03, 2019 at 09:48:08AM +0800, Leo Yan escreveu:
> > On Tue, Jul 02, 2019 at 01:07:43PM +0200, Jiri Olsa wrote:
> > > On Tue, Jul 02, 2019 at 06:34:09PM +0800, Leo Yan wrote:
> > > > When I used static checker Smatch for perf building, the main target is
> > > > to check if there have any potential issues in Arm cs-etm code.  So
> > > > finally I get many reporting for errors/warnings.
> > > > 
> > > > I used below command for using static checker with perf building:
> > > > 
> > > >   # make VF=1 CORESIGHT=1 -C tools/perf/ \
> > > >     CHECK="/root/Work/smatch/smatch --full-path" \
> > > >     CC=/root/Work/smatch/cgcc | tee smatch_reports.txt
> > > > 
> > > > I reviewed the errors one by one, if I understood some of these errors
> > > > so changed the code as I can, this patch set is the working result; but
> > > > still leave some errors due to I don't know what's the best way to fix
> > > > it.  There also have many inconsistent indenting warnings.  So I firstly
> > > > send out this patch set and let's see what's the feedback from public
> > > > reviewing.
> > > > 
> > > > Leo Yan (11):
> > > >   perf report: Smatch: Fix potential NULL pointer dereference
> > > >   perf stat: Smatch: Fix use-after-freed pointer
> > > >   perf top: Smatch: Fix potential NULL pointer dereference
> > > >   perf annotate: Smatch: Fix dereferencing freed memory
> > > >   perf trace: Smatch: Fix potential NULL pointer dereference
> > > >   perf hists: Smatch: Fix potential NULL pointer dereference
> > > >   perf map: Smatch: Fix potential NULL pointer dereference
> > > >   perf session: Smatch: Fix potential NULL pointer dereference
> > > >   perf intel-bts: Smatch: Fix potential NULL pointer dereference
> > > >   perf intel-pt: Smatch: Fix potential NULL pointer dereference
> > > >   perf cs-etm: Smatch: Fix potential NULL pointer dereference
> > > 
> > > from quick look it all looks good to me, nice tool ;-)
> > > 
> > > Acked-by: Jiri Olsa <jolsa@kernel.org>
> > 
> > Thanks for reviewing, Jiri.
> > 
> > @Arnaldo, Just want to check, will you firstly pick up 01~05, 07,
> > 08/11 patches if you think they are okay?  Or you want to wait me to
> > spin new patch set with all patches after I gather all comments?
> 
> I'm picking up the uncontrovertial, will push to my perf/core branch,
> continue from there, please.

Will do it.  Thank you much for amendment in these patches.

Leo.