[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 079/104] virtiofsd: fix memory leak on lo.source
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [PATCH 079/104] virtiofsd: fix memory leak on lo.source |
Date: |
Thu, 9 Jan 2020 17:38:53 +0000 |
User-agent: |
Mutt/1.13.0 (2019-11-30) |
* Daniel P. Berrangé (address@hidden) wrote:
> On Thu, Dec 12, 2019 at 04:38:39PM +0000, Dr. David Alan Gilbert (git) wrote:
> > From: Liu Bo <address@hidden>
> >
> > valgrind reported that lo.source is leaked on quiting, but it was defined
> > as (const char*) as it may point to a const string "/".
> >
> > Signed-off-by: Liu Bo <address@hidden>
> > ---
> > tools/virtiofsd/passthrough_ll.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/virtiofsd/passthrough_ll.c
> > b/tools/virtiofsd/passthrough_ll.c
> > index 33092de65a..45cf466178 100644
> > --- a/tools/virtiofsd/passthrough_ll.c
> > +++ b/tools/virtiofsd/passthrough_ll.c
> > @@ -2529,9 +2529,8 @@ int main(int argc, char *argv[])
> > fuse_log(FUSE_LOG_ERR, "source is not a directory\n");
> > exit(1);
> > }
> > -
> > } else {
> > - lo.source = "/";
> > + lo.source = strdup("/");
> > }
> > lo.root.is_symlink = false;
> > if (!lo.timeout_set) {
> > @@ -2610,5 +2609,7 @@ err_out1:
> > close(lo.root.fd);
> > }
> >
> > + free((char *)lo.source);
>
> Can we not change the 'lo_data' struct so that source is not const
> and thus avoid free'ing a const field ?
Done. Made that free(lo.source) and dropped the const.
Dave
>
> Regards,
> Daniel
> --
> |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org -o- https://fstop138.berrange.com :|
> |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK