diff mbox series

[v2] vhost-vdpa :Fix Coverity CID 1430270 / CID 1420267

Message ID 20200710064642.24505-1-lulu@redhat.com (mailing list archive)
State New, archived
Headers show
Series [v2] vhost-vdpa :Fix Coverity CID 1430270 / CID 1420267 | expand

Commit Message

Cindy Lu July 10, 2020, 6:46 a.m. UTC
In the function vhost_vdpa_dma_map/unmap, The struct msg was not initialized all its fields.

Signed-off-by: Cindy Lu <lulu@redhat.com>
---
 hw/virtio/vhost-vdpa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Peter Maydell July 10, 2020, 8:07 a.m. UTC | #1
On Fri, 10 Jul 2020 at 07:47, Cindy Lu <lulu@redhat.com> wrote:
>
> In the function vhost_vdpa_dma_map/unmap, The struct msg was not initialized all its fields.
>
> Signed-off-by: Cindy Lu <lulu@redhat.com>
> ---
>  hw/virtio/vhost-vdpa.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM
Jason Wang July 10, 2020, 9:14 a.m. UTC | #2
On 2020/7/10 下午2:46, Cindy Lu wrote:
> In the function vhost_vdpa_dma_map/unmap, The struct msg was not initialized all its fields.
>
> Signed-off-by: Cindy Lu <lulu@redhat.com>


Acked-by: Jason Wang <jasowang@redhat.com>


> ---
>   hw/virtio/vhost-vdpa.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> index a3d17fe0f9..b9265f3761 100644
> --- a/hw/virtio/vhost-vdpa.c
> +++ b/hw/virtio/vhost-vdpa.c
> @@ -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;
>
Li Qiang July 10, 2020, 10:29 a.m. UTC | #3
Cindy Lu <lulu@redhat.com> 于2020年7月10日周五 下午2:47写道:
>
> In the function vhost_vdpa_dma_map/unmap, The struct msg was not initialized all its fields.
>
> Signed-off-by: Cindy Lu <lulu@redhat.com>

Reviewed-by: Li Qiang <liq3ea@gmail.com>

> ---
>  hw/virtio/vhost-vdpa.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
> index a3d17fe0f9..b9265f3761 100644
> --- a/hw/virtio/vhost-vdpa.c
> +++ b/hw/virtio/vhost-vdpa.c
> @@ -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
>
>
Peter Maydell July 23, 2020, 5:55 p.m. UTC | #4
(trimming down the rather exuberant CC list)

On Fri, 10 Jul 2020 at 07:47, Cindy Lu <lulu@redhat.com> wrote:
>
> In the function vhost_vdpa_dma_map/unmap, The struct msg was not initialized all its fields.
>
> Signed-off-by: Cindy Lu <lulu@redhat.com>
> ---
>  hw/virtio/vhost-vdpa.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Michael, I guess this should go via your tree ?

thanks
-- PMM
Michael S. Tsirkin July 27, 2020, 1:29 p.m. UTC | #5
On Thu, Jul 23, 2020 at 06:55:08PM +0100, Peter Maydell wrote:
> (trimming down the rather exuberant CC list)
> 
> On Fri, 10 Jul 2020 at 07:47, Cindy Lu <lulu@redhat.com> wrote:
> >
> > In the function vhost_vdpa_dma_map/unmap, The struct msg was not initialized all its fields.
> >
> > Signed-off-by: Cindy Lu <lulu@redhat.com>
> > ---
> >  hw/virtio/vhost-vdpa.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> Michael, I guess this should go via your tree ?
> 
> thanks
> -- PMM
Queues, thanks!
diff mbox series

Patch

diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index a3d17fe0f9..b9265f3761 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -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;