All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Haotian Li <lihaotian9@huawei.com>
Cc: virtio-fs@redhat.com, linfeilong@huawei.com, qemu-devel@nongnu.org
Subject: Re: [Virtio-fs] [PATCH 3/3] virtiofsd: check whether strdup lo.source return NULL in main func
Date: Wed, 11 Nov 2020 19:55:00 +0000	[thread overview]
Message-ID: <20201111195500.GP3232@work-vm> (raw)
In-Reply-To: <f1e48ca8-d6de-d901-63c8-4f4024bda518@huawei.com>

* Haotian Li (lihaotian9@huawei.com) wrote:
> In main func, strdup lo.source may fail. So check whether strdup
> lo.source return NULL before using it.
> 
> Signed-off-by: Haotian Li <lihaotian9@huawei.com>
> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> ---
>  tools/virtiofsd/passthrough_ll.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
> index 3e9bbc7a04..0c11134fb5 100644
> --- a/tools/virtiofsd/passthrough_ll.c
> +++ b/tools/virtiofsd/passthrough_ll.c
> @@ -3525,6 +3525,10 @@ int main(int argc, char *argv[])
>          }
>      } else {
>          lo.source = strdup("/");
> +        if (!lo.source) {
> +            fuse_log(FUSE_LOG_ERR, "failed to strdup source\n");
> +            goto err_out1;
> +        }
>      }
> 

(It's interesting we use exit's in some places, goto's in others)

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

>      if (lo.xattrmap) {
> -- 
> 
> _______________________________________________
> Virtio-fs mailing list
> Virtio-fs@redhat.com
> https://www.redhat.com/mailman/listinfo/virtio-fs
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


  reply	other threads:[~2020-11-11 19:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-11  1:04 [Virtio-fs] [PATCH v3 0/3] virtiofsd: fix some accessing NULL pointer problem Haotian Li
2020-11-11  1:04 ` Haotian Li
2020-11-11  1:05 ` [Virtio-fs] [PATCH 1/3] tools/virtiofsd/buffer.c: check whether buf is NULL in fuse_bufvec_advance func Haotian Li
2020-11-11  1:05   ` Haotian Li
2020-11-11 19:59   ` [Virtio-fs] " Dr. David Alan Gilbert
2020-11-11  1:09 ` [Virtio-fs] [PATCH 2/3] virtiofsd: check whether lo_map_reserve returns NULL in, main func Haotian Li
2020-11-11  1:09   ` Haotian Li
2020-11-11 19:52   ` [Virtio-fs] " Dr. David Alan Gilbert
2020-11-11  1:10 ` [Virtio-fs] [PATCH 3/3] virtiofsd: check whether strdup lo.source return NULL in " Haotian Li
2020-11-11  1:10   ` Haotian Li
2020-11-11 19:55   ` Dr. David Alan Gilbert [this message]
2020-11-12 16:25 ` [Virtio-fs] [PATCH v3 0/3] virtiofsd: fix some accessing NULL pointer problem Dr. David Alan Gilbert
2020-11-12 16:25   ` 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=20201111195500.GP3232@work-vm \
    --to=dgilbert@redhat.com \
    --cc=lihaotian9@huawei.com \
    --cc=linfeilong@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --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.