From: John Levon <john.levon@nutanix.com>
To: qemu-devel@nongnu.org
Cc: "Thanos Makatos" <thanos.makatos@nutanix.com>,
"Cédric Le Goater" <clg@redhat.com>,
"Alex Williamson" <alex.williamson@redhat.com>,
"John Levon" <john.levon@nutanix.com>
Subject: [PATCH v2 4/4] hw/vfio-user: fix use of uninitialized variable
Date: Tue, 15 Jul 2025 07:52:46 +0200 [thread overview]
Message-ID: <20250715055246.422834-5-john.levon@nutanix.com> (raw)
In-Reply-To: <20250715055246.422834-1-john.levon@nutanix.com>
Coverity reported:
CID 1611805: Uninitialized variables
in vfio_user_dma_map(). This can occur in the happy path when
->async_ops was not set; as this doesn't typically happen, it wasn't
caught during testing.
Align both map and unmap implementations to initialize ret the same way
to resolve this.
Resolves: Coverity CID 1611805
Fixes: 18e899e6 ("vfio-user: implement VFIO_USER_DMA_MAP/UNMAP")
Reported-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: John Levon <john.levon@nutanix.com>
---
hw/vfio-user/container.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/hw/vfio-user/container.c b/hw/vfio-user/container.c
index d318e6a339..d589dd90f5 100644
--- a/hw/vfio-user/container.c
+++ b/hw/vfio-user/container.c
@@ -64,8 +64,6 @@ static int vfio_user_dma_unmap(const VFIOContainerBase *bcontainer,
0, &local_err)) {
error_report_err(local_err);
ret = -EFAULT;
- } else {
- ret = 0;
}
} else {
if (!vfio_user_send_wait(container->proxy, &msgp->hdr, NULL,
@@ -92,7 +90,7 @@ static int vfio_user_dma_map(const VFIOContainerBase *bcontainer, hwaddr iova,
bcontainer);
int fd = memory_region_get_fd(mrp);
Error *local_err = NULL;
- int ret;
+ int ret = 0;
VFIOUserFDs *fds = NULL;
VFIOUserDMAMap *msgp = g_malloc0(sizeof(*msgp));
@@ -135,8 +133,6 @@ static int vfio_user_dma_map(const VFIOContainerBase *bcontainer, hwaddr iova,
0, &local_err)) {
error_report_err(local_err);
ret = -EFAULT;
- } else {
- ret = 0;
}
} else {
VFIOUserFDs local_fds = { 1, 0, &fd };
--
2.43.0
next prev parent reply other threads:[~2025-07-15 5:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-15 5:52 [PATCH v2 0/4] vfio-user fixes John Levon
2025-07-15 5:52 ` [PATCH v2 1/4] hw/vfio-user: add Cédric Le Goater as a maintainer John Levon
2025-07-15 8:57 ` Mark Cave-Ayland
2025-07-15 5:52 ` [PATCH v2 2/4] hw/vfio: fix region fd initialization John Levon
2025-07-15 5:52 ` [PATCH v2 3/4] hw/vfio-user: wait for proxy close correctly John Levon
2025-07-15 9:01 ` Mark Cave-Ayland
2025-07-15 9:33 ` John Levon
2025-07-15 9:37 ` Cédric Le Goater
2025-07-15 5:52 ` John Levon [this message]
2025-07-15 5:56 ` [PATCH v2 0/4] vfio-user fixes Cédric Le Goater
2025-07-15 5:58 ` Cédric Le Goater
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=20250715055246.422834-5-john.levon@nutanix.com \
--to=john.levon@nutanix.com \
--cc=alex.williamson@redhat.com \
--cc=clg@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thanos.makatos@nutanix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).