qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 079/104] virtiofsd: fix memory leak on lo.source


From: Daniel P . Berrangé
Subject: Re: [PATCH 079/104] virtiofsd: fix memory leak on lo.source
Date: Tue, 7 Jan 2020 11:37:34 +0000
User-agent: Mutt/1.12.1 (2019-06-15)

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 ?


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 :|




reply via email to

[Prev in Thread] Current Thread [Next in Thread]