From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Liu Bo <bo.liu@linux.alibaba.com>
Cc: virtio-fs@redhat.com
Subject: Re: [Virtio-fs] [PATCH v2 2/5] virtiofsd: fix memory leak on lo.source
Date: Fri, 7 Jun 2019 13:15:18 +0100 [thread overview]
Message-ID: <20190607121518.GG2631@work-vm> (raw)
In-Reply-To: <1559857436-52685-3-git-send-email-bo.liu@linux.alibaba.com>
* Liu Bo (bo.liu@linux.alibaba.com) wrote:
> 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 <bo.liu@linux.alibaba.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
> contrib/virtiofsd/passthrough_ll.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/virtiofsd/passthrough_ll.c b/contrib/virtiofsd/passthrough_ll.c
> index b58708f..959d74d 100644
> --- a/contrib/virtiofsd/passthrough_ll.c
> +++ b/contrib/virtiofsd/passthrough_ll.c
> @@ -2269,9 +2269,8 @@ int main(int argc, char *argv[])
> err(1, "failed to stat source (\"%s\")", lo.source);
> if (!S_ISDIR(stat.st_mode))
> errx(1, "source is not a directory");
> -
> } else {
> - lo.source = "/";
> + lo.source = strdup("/");
> }
> lo.root.is_symlink = false;
> if (!lo.timeout_set) {
> @@ -2333,5 +2332,7 @@ err_out1:
> if (lo.root.fd >= 0)
> close(lo.root.fd);
>
> + free((char *)lo.source);
> +
> return ret ? 1 : 0;
> }
> --
> 1.8.3.1
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2019-06-07 12:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-06 21:43 [Virtio-fs] [PATCH v2 0/5] virtiofsd: leak fixes Liu Bo
2019-06-06 21:43 ` [Virtio-fs] [PATCH v2 1/5] virtiofsd: cleanup allocated resource in se Liu Bo
2019-06-07 12:09 ` Dr. David Alan Gilbert
2019-06-06 21:43 ` [Virtio-fs] [PATCH v2 2/5] virtiofsd: fix memory leak on lo.source Liu Bo
2019-06-07 12:15 ` Dr. David Alan Gilbert [this message]
2019-06-06 21:43 ` [Virtio-fs] [PATCH v2 3/5] virtiofsd: fix memory leak on lo.inodes hashmap Liu Bo
2019-06-06 21:43 ` [Virtio-fs] [PATCH v2 4/5] virtiofsd: fix error handling in main() Liu Bo
2019-06-06 21:43 ` [Virtio-fs] [PATCH v2 5/5] virtiofsd: add helper for lo_data cleanup Liu Bo
2019-06-07 16:19 ` [Virtio-fs] [PATCH v2 0/5] virtiofsd: leak fixes Dr. David Alan Gilbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190607121518.GG2631@work-vm \
--to=dgilbert@redhat.com \
--cc=bo.liu@linux.alibaba.com \
--cc=virtio-fs@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.