From: Haotian Li References: <3477d902-ace9-1aa1-531a-9d20d6e93a05@huawei.com> Message-ID: Date: Wed, 11 Nov 2020 09:10:38 +0800 MIME-Version: 1.0 In-Reply-To: <3477d902-ace9-1aa1-531a-9d20d6e93a05@huawei.com> Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit Subject: [Virtio-fs] [PATCH 3/3] virtiofsd: check whether strdup lo.source return NULL in main func List-Id: Development discussions about virtio-fs List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, virtio-fs@redhat.com Cc: linfeilong@huawei.com In main func, strdup lo.source may fail. So check whether strdup lo.source return NULL before using it. Signed-off-by: Haotian Li Signed-off-by: Zhiqiang Liu --- 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; + } } if (lo.xattrmap) { --