qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] libvhost-user: Zero memory allocated for VuVirtqInflightDesc
@ 2019-11-19  7:57 elohimes
  2019-11-19  7:59 ` Marc-André Lureau
  0 siblings, 1 reply; 2+ messages in thread
From: elohimes @ 2019-11-19  7:57 UTC (permalink / raw)
  To: mst, marcandre.lureau; +Cc: Xie Yongji, qemu-devel

From: Xie Yongji <xieyongji@baidu.com>

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 <marcandre.lureau@redhat.com>
Signed-off-by: Xie Yongji <xieyongji@baidu.com>
---
 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;
         }
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] libvhost-user: Zero memory allocated for VuVirtqInflightDesc
  2019-11-19  7:57 [PATCH v2] libvhost-user: Zero memory allocated for VuVirtqInflightDesc elohimes
@ 2019-11-19  7:59 ` Marc-André Lureau
  0 siblings, 0 replies; 2+ messages in thread
From: Marc-André Lureau @ 2019-11-19  7:59 UTC (permalink / raw)
  To: Yongji Xie; +Cc: Xie Yongji, qemu-devel, Michael S . Tsirkin

On Tue, Nov 19, 2019 at 11:58 AM <elohimes@gmail.com> wrote:
>
> From: Xie Yongji <xieyongji@baidu.com>
>
> 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 <marcandre.lureau@redhat.com>
> Signed-off-by: Xie Yongji <xieyongji@baidu.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  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;
>          }
> --
> 2.17.1
>



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-19  8:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-19  7:57 [PATCH v2] libvhost-user: Zero memory allocated for VuVirtqInflightDesc elohimes
2019-11-19  7:59 ` Marc-André Lureau

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).