On Mon, Feb 25, 2019 at 12:07:22PM -0300, Arnaldo Carvalho de Melo wrote: SNIP
> > > > +} > > > > + > > > > static int open_file_read(struct perf_data *data) > > > > { > > > > struct stat st; > > > > @@ -254,6 +270,22 @@ static int open_file_dup(struct perf_data *data) > > > > return open_file(data); > > > > } > > > > > > > > +static int open_dir(struct perf_data *data) > > > > +{ > > > > + if (perf_data__is_write(data) && > > > > + mkdir(data->path, S_IRWXU) < 0) > > > > + return -1; > > > > + > > > > + /* > > > > + * So far we open only the header, so we > > > > + * can read the data version and layout. > > > > + */ > > > > + if (asprintf(&data->file.path, "%s/header", data->path) < 0) > > > > + return -ENOMEM; > > > > > > so, if this fails, then we should unwind the mkdir, if it was > > > performed, so that we leave things as they were before calling > > > open_dir(), right? > > > > I think we need to some global solution on this, > > If we don't add more, that would be a good thing :-) > > The other parts also need to be investigated to see what is best in that > case, but here, undoing the mkdir() if the asprintf() fails is the right > thing to do :-) true ;-) will resend thanks, jirka