From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Ameer Hamza <amhamza.mgc@gmail.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
amhamza.mgc@gmail.com, pbonzini@redhat.com, seanjc@google.com,
wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org,
tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com
Subject: Re: [PATCH] KVM: x86: fix for missing initialization of return status variable
Date: Mon, 06 Dec 2021 10:06:26 +0100 [thread overview]
Message-ID: <87ee6q6r1p.fsf@redhat.com> (raw)
In-Reply-To: <20211205194719.16987-1-amhamza.mgc@gmail.com>
Ameer Hamza <amhamza.mgc@gmail.com> writes:
> If undefined ioctl number is passed to the kvm_vcpu_ioctl_device_attr
> function, it should return with error status.
>
> Addresses-Coverity: 1494124 ("Uninitialized scalar variable")
>
> Signed-off-by: Ameer Hamza <amhamza.mgc@gmail.com>
> ---
> arch/x86/kvm/x86.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index e0aa4dd53c7f..55b90c185717 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -5001,7 +5001,7 @@ static int kvm_vcpu_ioctl_device_attr(struct kvm_vcpu *vcpu,
> void __user *argp)
> {
> struct kvm_device_attr attr;
> - int r;
> + int r = -EINVAL;
>
> if (copy_from_user(&attr, argp, sizeof(attr)))
> return -EFAULT;
The reported issue is not real, kvm_vcpu_ioctl_device_attr() is never
called with anything but [KVM_HAS_DEVICE_ATTR, KVM_GET_DEVICE_ATTR,
KVM_SET_DEVICE_ATTR] as 'ioctl' and the switch below covers all
three. Instead of initializing 'r' we could've added a 'default' case to
the switch, either returning something like EINVAL or just BUG(). Hope
it'll silence coverity.
--
Vitaly
next prev parent reply other threads:[~2021-12-06 9:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-05 19:47 [PATCH] KVM: x86: fix for missing initialization of return status variable Ameer Hamza
2021-12-06 9:06 ` Vitaly Kuznetsov [this message]
2021-12-06 9:32 ` Ameer Hamza
2021-12-06 10:24 ` [PATCH v2] " Ameer Hamza
2021-12-06 15:37 ` Sean Christopherson
2021-12-06 16:08 ` Ameer Hamza
2021-12-06 16:45 ` [PATCH v3] " Ameer Hamza
2021-12-06 17:02 ` Sean Christopherson
2021-12-06 17:27 ` Ameer Hamza
2021-12-06 18:01 ` Sean Christopherson
2021-12-06 18:40 ` Ameer Hamza
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=87ee6q6r1p.fsf@redhat.com \
--to=vkuznets@redhat.com \
--cc=amhamza.mgc@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=wanpengli@tencent.com \
--cc=x86@kernel.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).