libvhost-user: Zero memory allocated for VuVirtqInflightDesc
PATCH v2 1/1 libvhost-user: Zero memory allocated for VuVirtqInflightDesc
From: Xie Yongji <[email protected]>
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 <[email protected]>
Signed-off-by Xie Yongji <[email protected]>
--- contrib/libvhost-user/libvhost-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/libvhost-user/libvhost-user.c +1 -1
@@ -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 ; }
Signature · 1 line
2.17.1
Quoted 11 lines · On Tue, Nov 19, 2019 at 11:58 AM <[email protected]> wrote:
From: Xie Yongji <[email protected]>
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 inshared memory")
Reported-by Marc-André Lureau <[email protected]>Signed-off-by Xie Yongji <[email protected]>
Reviewed-by Marc-André Lureau <[email protected]>
Quoted 20 lines
--- contrib/libvhost-user/libvhost-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)contrib/libvhost-user/libvhost-user.c +1
-2@@ -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