Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>
Subject: Re: Coverity CID 714665: vfio_ext_cap_len() use of uninitialized variable
Date: Thu, 03 Apr 2014 10:55:23 -0600	[thread overview]
Message-ID: <1396544123.3215.8.camel@ul30vt.home> (raw)
In-Reply-To: <CAErSpo4-sW3Ge55oAzz=Xm1rbU1UZWQ=jBKUtL28yeTx-YOapw@mail.gmail.com>

On Thu, 2014-04-03 at 10:48 -0600, Bjorn Helgaas wrote:
> On Thu, Apr 3, 2014 at 9:53 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> > Coverity complains that "byte" is used uninitialized in
> > drivers/vfio/pci/vfio_pci_config.c in vfio_ext_cap_len():
> >
> > 1139                        sts = byte & PCI_TPH_CAP_ST_MASK;
> > 1140                        sts >>= PCI_TPH_CAP_ST_SHIFT;
> > 1141                        return PCI_TPH_BASE_SIZEOF + round_up(sts * 2, 4);
> >
> > This is CID 714665.
> 
> I think "dword" was probably intended instead of "byte".  Changing
> that would also fix CID 715156:
> 
> 1136                if ((dword & PCI_TPH_CAP_LOC_MASK) == PCI_TPH_LOC_CAP) {
> 1137                        int sts;
> 1138
>     CID 714665: Uninitialized scalar variable (UNINIT) [select issue]
> 
> CID 715156 (#1 of 1): Operands don't affect result (CONSTANT_EXPRESSION_RESULT)
> result_independent_of_operands: byte & 0x7ff0000 is always 0
> regardless of the values of its operands. This occurs as the operand
> of assignment.
> 1139                        sts = byte & PCI_TPH_CAP_ST_MASK;

Yes, using byte looks like a cut-n-paste error, it should have been
dword.  The size calculation also looks wrong since the field is an N-1
value but we don't seem to be incrementing it.  I'll post a patch that
fixes both.  Thanks,

Alex

      reply	other threads:[~2014-04-03 16:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-03 15:53 Coverity CID 714665: vfio_ext_cap_len() use of uninitialized variable Bjorn Helgaas
2014-04-03 16:48 ` Bjorn Helgaas
2014-04-03 16:55   ` Alex Williamson [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=1396544123.3215.8.camel@ul30vt.home \
    --to=alex.williamson@redhat.com \
    --cc=bhelgaas@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-pci@vger.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