linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cai Huoqing <caihuoqing@baidu.com>
To: <sgarzare@redhat.com>, <mst@redhat.com>, <jasowang@redhat.com>
Cc: <virtualization@lists.linux-foundation.org>,
	<linux-kernel@vger.kernel.org>,
	Cai Huoqing <caihuoqing@baidu.com>
Subject: [PATCH 2/2] virtio_ring: fix error - 'prev' and 'head_flags' may be used uninitialized in this function
Date: Wed, 14 Jul 2021 10:28:54 +0800	[thread overview]
Message-ID: <20210714022854.1077-3-caihuoqing@baidu.com> (raw)
In-Reply-To: <20210714022854.1077-1-caihuoqing@baidu.com>

when run "make virtio" in linux/tools,
the error: "'prev' and 'head_flags' may be used
uninitialized in this function" occurs

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
---
 drivers/virtio/virtio_ring.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 89bfe46a8a7f..290bdf8a3d36 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -486,7 +486,7 @@ static inline int virtqueue_add_split(struct virtqueue *_vq,
        struct vring_virtqueue *vq = to_vvq(_vq);
        struct scatterlist *sg;
        struct vring_desc *desc;
-       unsigned int i, n, avail, descs_used, prev, err_idx;
+       unsigned int i, n, avail, descs_used, prev = 0, err_idx;
        int head;
        bool indirect;

@@ -1173,8 +1173,8 @@ static inline int virtqueue_add_packed(struct virtqueue *_vq,
        struct vring_packed_desc *desc;
        struct scatterlist *sg;
        unsigned int i, n, c, descs_used, err_idx;
-       __le16 head_flags, flags;
-       u16 head, id, prev, curr, avail_used_flags;
+       __le16 head_flags = 0, flags;
+       u16 head, id, prev = 0, curr, avail_used_flags;

        START_USE(vq);

--
2.25.1


      parent reply	other threads:[~2021-07-14  2:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-14  2:28 [PATCH 0/2] virtio_ring: fix errors to make virtio tools Cai Huoqing
2021-07-14  2:28 ` [PATCH 1/2] virtio_ring: fix error - unknown type name 'spinlock_t' Cai Huoqing
2021-07-19  5:14   ` Cai,Huoqing
2021-07-14  2:28 ` Cai Huoqing [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210714022854.1077-3-caihuoqing@baidu.com \
    --to=caihuoqing@baidu.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=sgarzare@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).