[LTP] [PATCH v2 2/2] syscalls/fanotify21: add new test checking the returned pidfd from fanotify in FAN_REPORT_PIDFD mode
Amir Goldstein
amir73il@gmail.com
Tue Nov 9 11:34:43 CET 2021
On Tue, Nov 9, 2021 at 11:36 AM Matthew Bobrowski <repnop@google.com> wrote:
>
> On Fri, Nov 05, 2021 at 06:21:56AM +0200, Amir Goldstein wrote:
> > > +next_event:
> > > + i += event->event_len;
> > > + if (event->fd >= 0)
> > > + SAFE_CLOSE(event->fd);
> > > +
> > > + if (info && info->pidfd >= 0)
> > > + SAFE_CLOSE(info->pidfd);
> > > +
> > > + if (event_pidfd_fdinfo)
> > > + free(event_pidfd_fdinfo);
> >
> > Need to reset event_pidfd_fdinfo = NULL
> > to avoid double free in do_cleanup
>
> But, the variable event_pidfd_fdinfo is not referenced nor is visible
> outside the scope of the do_test() function and therefore no double
> free would occur, right?
>
> > > + }
> > > +}
> > > +
> > > +static void do_cleanup(void)
> > > +{
> > > + if (fanotify_fd >= 0)
> > > + SAFE_CLOSE(fanotify_fd);
> > > +
> > > + if (self_pidfd_fdinfo)
> > > + free(self_pidfd_fdinfo);
>
> Variables self_pidfd_fdinfo do_cleanup() and event_pidfd_fdinfo
> do_test() are different.
>
Right. my bad :)
Thanks,
Amir.
More information about the ltp
mailing list