Re: [PATCH 07/24] perf daemon: Add config file change check
From: Jiri Olsa
Date: Thu Feb 04 2021 - 09:55:09 EST
On Wed, Feb 03, 2021 at 06:13:59PM -0300, Arnaldo Carvalho de Melo wrote:
SNIP
> > #include <sys/types.h>
> > #include <sys/socket.h>
> > #include <sys/un.h>
> > @@ -73,6 +75,7 @@ struct session {
> > struct daemon {
> > const char *config;
> > char *config_real;
> > + char *config_base;
> > const char *base_user;
> > char *base;
> > struct list_head sessions;
> > @@ -493,6 +496,7 @@ static void daemon__free(struct daemon *daemon)
> > session__remove(session);
> >
> > free(daemon->config_real);
> > + free(daemon->config_base);
> > free(daemon->base);
>
> Please replace those with zfree()
ok
>
> > }
> >
> > @@ -535,6 +539,83 @@ static int daemon__reconfig(struct daemon *daemon)
> > return 0;
> > }
> >
> > +static int setup_config_changes(struct daemon *daemon)
> > +{
> > + char *basen = strdup(daemon->config_real);
> > + char *dirn = strdup(daemon->config_real);
> > + char *base, *dir;
> > + int fd, wd;
> > +
> > + if (!dirn || !basen)
> > + return -ENOMEM;
>
> This may leak one of them
right, will fix
thanks,
jirka