This patch fixes the following build failure seen on CentOS 8
with gcc 12.1 because of uninitialized struct variable:

  [..]
../lib/vhost/virtio_net.c:1159:18: warning: 'buf_vec[0].buf_addr' may be used 
uninitialized [-Wmaybe-uninitialized]
1159 |         buf_addr = buf_vec[vec_idx].buf_addr;
     |         ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
  [..]

Fixes: 873e8dad6f49 ("vhost: support packed ring in async datapath")

Signed-off-by: Min Zhou <zhou...@loongson.cn>
---
 lib/vhost/virtio_net.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
index 35fa4670fd..4878bb2d8a 100644
--- a/lib/vhost/virtio_net.c
+++ b/lib/vhost/virtio_net.c
@@ -1837,6 +1837,7 @@ virtio_dev_rx_async_packed(struct virtio_net *dev, struct 
vhost_virtqueue *vq,
 {
        struct buf_vector buf_vec[BUF_VECTOR_MAX];
 
+       memset(buf_vec, 0, sizeof(buf_vec));
        if (unlikely(vhost_enqueue_async_packed(dev, vq, pkt, buf_vec,
                                        nr_descs, nr_buffers) < 0)) {
                VHOST_LOG_DATA(dev->ifname, DEBUG, "failed to get enough desc 
from vring\n");
-- 
2.31.1

Reply via email to