From: Barret Rhoden <brho@google.com>
To: pbonzini@redhat.com
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] KVM: squelch uninitialized variable warning
Date: Thu, 9 Jan 2020 14:58:55 -0500 [thread overview]
Message-ID: <20200109195855.17353-1-brho@google.com> (raw)
If gfn_to_hva_many() fails, __kvm_gfn_to_hva_cache_init() will return an
error. Before it does, it might use nr_pages_avail, which my compiler
complained about:
virt/kvm/kvm_main.c:2193:13: warning: 'nr_pages_avail' may be
used uninitialized in this function [-Wmaybe-uninitialized]
start_gfn += nr_pages_avail;
Signed-off-by: Barret Rhoden <brho@google.com>
---
virt/kvm/kvm_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index d9aced677ddd..f8249b153d33 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2172,7 +2172,7 @@ static int __kvm_gfn_to_hva_cache_init(struct kvm_memslots *slots,
gfn_t start_gfn = gpa >> PAGE_SHIFT;
gfn_t end_gfn = (gpa + len - 1) >> PAGE_SHIFT;
gfn_t nr_pages_needed = end_gfn - start_gfn + 1;
- gfn_t nr_pages_avail;
+ gfn_t nr_pages_avail = 0;
int r = start_gfn <= end_gfn ? 0 : -EINVAL;
ghc->gpa = gpa;
--
2.25.0.rc1.283.g88dfdc4193-goog
next reply other threads:[~2020-01-09 19:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-09 19:58 Barret Rhoden [this message]
2020-01-09 22:04 ` [PATCH] KVM: squelch uninitialized variable warning Sean Christopherson
2020-01-18 20:19 ` Paolo Bonzini
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=20200109195855.17353-1-brho@google.com \
--to=brho@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.