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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 24 Feb 2019 14:32:27 +0100
From:   Jiri Olsa <jolsa@...hat.com>
To:     Namhyung Kim <namhyung@...nel.org>
Cc:     Jiri Olsa <jolsa@...nel.org>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        lkml <linux-kernel@...r.kernel.org>,
        Ingo Molnar <mingo@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Peter Zijlstra <a.p.zijlstra@...llo.nl>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Stephane Eranian <eranian@...gle.com>,
        Alexey Budankov <alexey.budankov@...ux.intel.com>
Subject: Re: [PATCH 05/17] perf data: Add perf_data__(create_dir|close_dir)
 functions

On Sat, Feb 23, 2019 at 02:07:53PM +0900, Namhyung Kim wrote:

SNIP

> > +static void close_dir(struct perf_data_file *files, int nr)
> > +{
> > +       while (--nr >= 1) {
> > +               close(files[nr].fd);
> > +               free(files[nr].path);
> > +       }
> > +       free(files);
> > +}
> > +
> > +void perf_data__close_dir(struct perf_data *data)
> > +{
> > +       close_dir(data->dir.files, data->dir.nr);
> > +}
> > +
> > +int perf_data__create_dir(struct perf_data *data, int nr)
> > +{
> > +       struct perf_data_file *files = NULL;
> > +       int i, ret = -1;
> > +
> > +       files = malloc(nr * sizeof(*files));
> > +       if (!files)
> > +               return -ENOMEM;
> > +
> > +       data->dir.files = files;
> > +       data->dir.nr    = 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)
> > +                       goto out_err;
> > +
> > +               ret = open(file->path, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR);
> > +               if (ret < 0)
> > +                       goto out_err;
> 
> It seems you need to free the file->path here.

it'll be freed in the close_dir call below,
I need to call zalloc to make sure it's ok

jirka

> 
> Thanks,
> Namhyung
> 
> 
> > +
> > +               file->fd = ret;
> > +       }
> > +
> > +       return 0;
> > +
> > +out_err:
> > +       close_dir(files, i);
> > +       return ret;
> > +}
> > +
> >  static bool check_pipe(struct perf_data *data)
> >  {
> >         struct stat st;

SNIP

Powered by blists - more mailing lists