All of lore.kernel.org
 help / color / mirror / Atom feed
* Coverity CID 714665: vfio_ext_cap_len() use of uninitialized variable
@ 2014-04-03 15:53 Bjorn Helgaas
  2014-04-03 16:48 ` Bjorn Helgaas
  0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Helgaas @ 2014-04-03 15:53 UTC (permalink / raw)
  To: Alex Williamson; +Cc: kvm, linux-pci

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Coverity CID 714665: vfio_ext_cap_len() use of uninitialized variable
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Helgaas @ 2014-04-03 16:48 UTC (permalink / raw)
  To: Alex Williamson; +Cc: kvm, linux-pci

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;

Bjorn

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Coverity CID 714665: vfio_ext_cap_len() use of uninitialized variable
  2014-04-03 16:48 ` Bjorn Helgaas
@ 2014-04-03 16:55   ` Alex Williamson
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Williamson @ 2014-04-03 16:55 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: kvm, linux-pci

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-04-03 16:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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.