Skip to contentSkip to conversation

vhost-vdpa :Fix Coverity CID 1430270 / CID 1420267

PATCH In review Cindy Lu 5 participants 6 messages Jul 10, 2020 – Jul 27, 2020

lore
Share & tools
lore

Cindy Lu

author
#0 lore raw

PATCH v2 1/1 vhost-vdpa :Fix Coverity CID 1430270 / CID 1420267

In the function vhost_vdpa_dma_map/unmap, The struct msg was not initialized all its fields.

---
 hw/virtio/vhost-vdpa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/vhost-vdpa.c +2 -2
index a3d17fe0f9..b9265f3761 100644
@@ -38,7 +38,7 @@ static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *section)
 static int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
                               void *vaddr, bool readonly)
 {
-    struct vhost_msg_v2 msg;
+    struct vhost_msg_v2 msg = {};
     int fd = v->device_fd;
     int ret = 0;
 
@@ -61,7 +61,7 @@ static int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
 static int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, hwaddr iova,
                                 hwaddr size)
 {
-    struct vhost_msg_v2 msg;
+    struct vhost_msg_v2 msg = {};
     int fd = v->device_fd;
     int ret = 0;
 
Signature · 1 line
2.21.1
Acked-by on v2 1/1
#2 lore raw
In reply to Cindy Lu
Quoted 3 lines · Cindy Lu

In the function vhost_vdpa_dma_map/unmap, The struct msg was not initialized all its fields.

Quoted 26 lines
---
  hw/virtio/vhost-vdpa.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/vhost-vdpa.c +2 -2
index a3d17fe0f9..b9265f3761 100644
@@ -38,7 +38,7 @@ static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *section)
  static int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
                                void *vaddr, bool readonly)
  {
-    struct vhost_msg_v2 msg;
+    struct vhost_msg_v2 msg = {};
      int fd = v->device_fd;
      int ret = 0;
 
@@ -61,7 +61,7 @@ static int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
  static int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, hwaddr iova,
                                  hwaddr size)
  {
-    struct vhost_msg_v2 msg;
+    struct vhost_msg_v2 msg = {};
      int fd = v->device_fd;
      int ret = 0;
 
Reviewed-by on v2 1/1
#3 lore raw
In reply to Cindy Lu
Quoted 4 lines · Cindy Lu <[email protected]> 于2020年7月10日周五 下午2:47写道:

In the function vhost_vdpa_dma_map/unmap, The struct msg was not initialized all its fields.

Quoted 30 lines
---
 hw/virtio/vhost-vdpa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/vhost-vdpa.c +2 -3
index a3d17fe0f9..b9265f3761 100644
@@ -38,7 +38,7 @@ static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *section)
 static int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
                               void *vaddr, bool readonly)
 {
-    struct vhost_msg_v2 msg;
+    struct vhost_msg_v2 msg = {};
     int fd = v->device_fd;
     int ret = 0;
 
@@ -61,7 +61,7 @@ static int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size,
 static int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, hwaddr iova,
                                 hwaddr size)
 {
-    struct vhost_msg_v2 msg;
+    struct vhost_msg_v2 msg = {};
     int fd = v->device_fd;
     int ret = 0;
 
--

2.21.1

#4 lore raw
In reply to Cindy Lu

(trimming down the rather exuberant CC list)

Quoted 7 lines · Cindy Lu

In the function vhost_vdpa_dma_map/unmap, The struct msg was not initialized all its fields.

---
 hw/virtio/vhost-vdpa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Michael, I guess this should go via your tree ?

thanks
-- PMM

#5 lore raw
Quoted 11 lines · Peter Maydell

(trimming down the rather exuberant CC list)

Quoted 7 lines · Cindy Lu

In the function vhost_vdpa_dma_map/unmap, The struct msg was not initialized all its fields.

---
 hw/virtio/vhost-vdpa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 4 lines

Michael, I guess this should go via your tree ?

thanks
-- PMM

Queues, thanks!