[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YH26d0r10woPIoFB@kernel.org>
Date: Mon, 19 Apr 2021 14:14:31 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Jiri Olsa <jolsa@...hat.com>
Cc: Zhen Lei <thunder.leizhen@...wei.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Namhyung Kim <namhyung@...nel.org>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/1] perf data: Fix error return code in
perf_data__create_dir()
Em Thu, Apr 15, 2021 at 01:38:40PM +0200, Jiri Olsa escreveu:
> On Thu, Apr 15, 2021 at 04:34:16PM +0800, Zhen Lei wrote:
> > Although 'ret' has been initialized to -1, but it will be reassigned by
> > the "ret = open(...)" statement in the for loop. So that, the value of
> > 'ret' is unknown when asprintf() failed.
> >
> > Reported-by: Hulk Robot <hulkci@...wei.com>
> > Signed-off-by: Zhen Lei <thunder.leizhen@...wei.com>
>
> Acked-by: Jiri Olsa <jolsa@...hat.com>
Thanks, applied.
- Arnaldo
> thanks,
> jirka
>
> > ---
> > tools/perf/util/data.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
> > index f29af4fc3d09390..8fca4779ae6a8e9 100644
> > --- a/tools/perf/util/data.c
> > +++ b/tools/perf/util/data.c
> > @@ -35,7 +35,7 @@ void perf_data__close_dir(struct perf_data *data)
> > int perf_data__create_dir(struct perf_data *data, int nr)
> > {
> > struct perf_data_file *files = NULL;
> > - int i, ret = -1;
> > + int i, ret;
> >
> > if (WARN_ON(!data->is_dir))
> > return -EINVAL;
> > @@ -51,7 +51,8 @@ int perf_data__create_dir(struct perf_data *data, int nr)
> > for (i = 0; i < nr; i++) {
> > struct perf_data_file *file = &files[i];
> >
> > - if (asprintf(&file->path, "%s/data.%d", data->path, i) < 0)
> > + ret = asprintf(&file->path, "%s/data.%d", data->path, i);
> > + if (ret < 0)
> > goto out_err;
> >
> > ret = open(file->path, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR);
> > --
> > 2.26.0.106.g9fadedd
> >
> >
>
--
- Arnaldo
Powered by blists - more mailing lists