From d9b3ade54ea7465093578cd0f792437198b572ac Mon Sep 17 00:00:00 2001 From: Xie Yongji Date: Tue, 19 Nov 2019 15:57:59 +0800 Subject: [PATCH 1/3] libvhost-user: Zero memory allocated for VuVirtqInflightDesc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use a zero-initialized VuVirtqInflightDesc struct to avoid that scan-build reports that vq->resubmit_list[0].counter may be garbage value in vu_check_queue_inflights(). Fixes: 5f9ff1eff ("libvhost-user: Support tracking inflight I/O in shared memory") Reported-by: Marc-André Lureau Signed-off-by: Xie Yongji Message-Id: <20191119075759.4334-1-xieyongji@baidu.com> Reviewed-by: Marc-André Lureau Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- contrib/libvhost-user/libvhost-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c index 68c27136ae..ec27b78ff1 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -992,7 +992,7 @@ vu_check_queue_inflights(VuDev *dev, VuVirtq *vq) vq->shadow_avail_idx = vq->last_avail_idx = vq->inuse + vq->used_idx; if (vq->inuse) { - vq->resubmit_list = malloc(sizeof(VuVirtqInflightDesc) * vq->inuse); + vq->resubmit_list = calloc(vq->inuse, sizeof(VuVirtqInflightDesc)); if (!vq->resubmit_list) { return -1; } From ec244b17391f8f9a16e91905a91a52dd77d3759f Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Tue, 19 Nov 2019 11:16:26 +0000 Subject: [PATCH 2/3] vhost-user-input: use free(elem) instead of g_free(elem) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The virtqueue element returned by vu_queue_pop() is allocated using malloc(3) by virtqueue_alloc_element(). Use the matching free(3) function instead of glib's g_free(). Signed-off-by: Stefan Hajnoczi Message-Id: <20191119111626.112206-1-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daudé --- contrib/vhost-user-input/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/vhost-user-input/main.c b/contrib/vhost-user-input/main.c index 449fd2171a..ef4b7769f2 100644 --- a/contrib/vhost-user-input/main.c +++ b/contrib/vhost-user-input/main.c @@ -77,7 +77,7 @@ static void vi_input_send(VuInput *vi, struct virtio_input_event *event) len = iov_from_buf(elem->in_sg, elem->in_num, 0, &vi->queue[i].event, sizeof(virtio_input_event)); vu_queue_push(dev, vq, elem, len); - g_free(elem); + free(elem); } vu_queue_notify(&vi->dev.parent, vq); @@ -153,7 +153,7 @@ static void vi_handle_sts(VuDev *dev, int qidx) 0, &event, sizeof(event)); vi_handle_status(vi, &event); vu_queue_push(dev, vq, elem, len); - g_free(elem); + free(elem); } vu_queue_notify(&vi->dev.parent, vq); From 6c77aa909e0eec6531e2398d0e9e60ec6a9339c6 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Wed, 20 Nov 2019 10:02:40 +0100 Subject: [PATCH 3/3] tests: acpi: always retain dumped ACPI tables in case of error If IASL wasn't able to parse expected file, test will just print warning "Warning! iasl couldn't parse the expected aml\n" and remove temporary table dumped from guest. Typically expected tables are always valid, with an exception when patchset introduces new tables. Make sure dumped tables are retained even if expected files are not valid, so one could have a chance to manualy check new tables. Signed-off-by: Igor Mammedov Message-Id: <1574240560-12538-1-git-send-email-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/bios-tables-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index 0b33fb265f..79f5da092f 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -437,11 +437,11 @@ static void test_acpi_asl(test_data *data) g_assert(!err || exp_err); if (g_strcmp0(asl->str, exp_asl->str)) { + sdt->tmp_files_retain = true; if (exp_err) { fprintf(stderr, "Warning! iasl couldn't parse the expected aml\n"); } else { - sdt->tmp_files_retain = true; exp_sdt->tmp_files_retain = true; fprintf(stderr, "acpi-test: Warning! %.4s mismatch. "