* [PATCH-for-5.2 v2] hw/virtio/vhost-backend: Fix Coverity CID 1432871
@ 2020-11-03 6:35 Philippe Mathieu-Daudé
2020-11-03 9:19 ` Stefano Garzarella
0 siblings, 1 reply; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-11-03 6:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Philippe Mathieu-Daudé, Michael S. Tsirkin
Fix uninitialized value issues reported by Coverity:
Field 'msg.reserved' is uninitialized when calling write().
While the 'struct vhost_msg' does not have a 'reserved' field,
we still initialize it to have the two parts of the function
consistent.
Reported-by: Coverity (CID 1432864: UNINIT)
Fixes: c471ad0e9bd ("vhost_net: device IOTLB support")
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
v2: comment 'struct vhost_msg' is also initialized (Peter)
---
hw/virtio/vhost-backend.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
index 88c8ecc9e03..222bbcc62de 100644
--- a/hw/virtio/vhost-backend.c
+++ b/hw/virtio/vhost-backend.c
@@ -257,7 +257,7 @@ static int vhost_kernel_send_device_iotlb_msg(struct vhost_dev *dev,
struct vhost_iotlb_msg *imsg)
{
if (dev->backend_cap & (1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2)) {
- struct vhost_msg_v2 msg;
+ struct vhost_msg_v2 msg = {};
msg.type = VHOST_IOTLB_MSG_V2;
msg.iotlb = *imsg;
@@ -267,7 +267,7 @@ static int vhost_kernel_send_device_iotlb_msg(struct vhost_dev *dev,
return -EFAULT;
}
} else {
- struct vhost_msg msg;
+ struct vhost_msg msg = {};
msg.type = VHOST_IOTLB_MSG;
msg.iotlb = *imsg;
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH-for-5.2 v2] hw/virtio/vhost-backend: Fix Coverity CID 1432871
2020-11-03 6:35 [PATCH-for-5.2 v2] hw/virtio/vhost-backend: Fix Coverity CID 1432871 Philippe Mathieu-Daudé
@ 2020-11-03 9:19 ` Stefano Garzarella
0 siblings, 0 replies; 2+ messages in thread
From: Stefano Garzarella @ 2020-11-03 9:19 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: Peter Maydell, qemu-devel, Michael S. Tsirkin
On Tue, Nov 03, 2020 at 07:35:41AM +0100, Philippe Mathieu-Daudé wrote:
>Fix uninitialized value issues reported by Coverity:
>
> Field 'msg.reserved' is uninitialized when calling write().
>
>While the 'struct vhost_msg' does not have a 'reserved' field,
>we still initialize it to have the two parts of the function
>consistent.
>
>Reported-by: Coverity (CID 1432864: UNINIT)
>Fixes: c471ad0e9bd ("vhost_net: device IOTLB support")
>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>---
>v2: comment 'struct vhost_msg' is also initialized (Peter)
>---
> hw/virtio/vhost-backend.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
>
>diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
>index 88c8ecc9e03..222bbcc62de 100644
>--- a/hw/virtio/vhost-backend.c
>+++ b/hw/virtio/vhost-backend.c
>@@ -257,7 +257,7 @@ static int vhost_kernel_send_device_iotlb_msg(struct vhost_dev *dev,
> struct vhost_iotlb_msg *imsg)
> {
> if (dev->backend_cap & (1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2)) {
>- struct vhost_msg_v2 msg;
>+ struct vhost_msg_v2 msg = {};
>
> msg.type = VHOST_IOTLB_MSG_V2;
> msg.iotlb = *imsg;
>@@ -267,7 +267,7 @@ static int vhost_kernel_send_device_iotlb_msg(struct vhost_dev *dev,
> return -EFAULT;
> }
> } else {
>- struct vhost_msg msg;
>+ struct vhost_msg msg = {};
>
> msg.type = VHOST_IOTLB_MSG;
> msg.iotlb = *imsg;
>--
>2.26.2
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-03 9:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-03 6:35 [PATCH-for-5.2 v2] hw/virtio/vhost-backend: Fix Coverity CID 1432871 Philippe Mathieu-Daudé
2020-11-03 9:19 ` Stefano Garzarella
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.