From: Bjorn Helgaas <bhelgaas@google.com>
To: Dave Airlie <airlied@redhat.com>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>
Subject: Re: Coverity CID 142811: pci_set_vga_state() operands don't affect result
Date: Fri, 4 Apr 2014 09:47:44 -0600 [thread overview]
Message-ID: <20140404154744.GA8549@google.com> (raw)
In-Reply-To: <CAErSpo6JNDFiV6tmDKKDdnod+skBHx6T-+JGvjCRRLsL98h_uQ@mail.gmail.com>
On Thu, Apr 03, 2014 at 02:43:05PM -0600, Bjorn Helgaas wrote:
> Coverity complains about this in drivers/pci/pci.c:
>
> CID 142811 (#1 of 1): Operands don't affect result (CONSTANT_EXPRESSION_RESULT)
> result_independent_of_operands: flags & (2U /* 1 << 1 */) &
> (command_bits & 4294967292U /* ~(1 | 2) */) is always 0 regardless of
> the values of its operands. This occurs as the logical operand of if.
>
> 4128 WARN_ON((flags & PCI_VGA_STATE_CHANGE_DECODES) &
> (command_bits & ~(PCI_COMMAND_IO|PCI_COMMAND_MEMORY)));
>
> This is a result of 3448a19da479 "vgaarb: use bridges to control VGA
> routing where possible."
>
> I wonder if that middle "&" was intended to be "&&"?
I propose the following patch for this. Unless there's objection, I'll
queue this for v3.16. I took the liberty of interpreting your email
responses as acks.
PCI: Fix incorrect vgaarb conditional in WARN_ON()
From: Bjorn Helgaas <bhelgaas@google.com>
3448a19da479 "vgaarb: use bridges to control VGA routing where possible"
added the "flags & PCI_VGA_STATE_CHANGE_DECODES" condition to an existing
WARN_ON(), but used bitwise AND (&) instead of logical AND (&&), so the
condition is never true. Replace with logical AND.
Found by Coverity (CID 142811).
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: David Airlie <airlied@redhat.com>
---
drivers/pci/pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7325d43bf030..39012831867e 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4125,7 +4125,7 @@ int pci_set_vga_state(struct pci_dev *dev, bool decode,
u16 cmd;
int rc;
- WARN_ON((flags & PCI_VGA_STATE_CHANGE_DECODES) & (command_bits & ~(PCI_COMMAND_IO|PCI_COMMAND_MEMORY)));
+ WARN_ON((flags & PCI_VGA_STATE_CHANGE_DECODES) && (command_bits & ~(PCI_COMMAND_IO|PCI_COMMAND_MEMORY)));
/* ARCH specific VGA enables */
rc = pci_set_vga_state_arch(dev, decode, command_bits, flags);
next prev parent reply other threads:[~2014-04-04 15:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-03 20:43 Coverity CID 142811: pci_set_vga_state() operands don't affect result Bjorn Helgaas
2014-04-04 0:06 ` Yinghai Lu
2014-04-04 0:12 ` David Airlie
2014-04-04 15:47 ` Bjorn Helgaas [this message]
2014-04-25 17:21 ` Bjorn Helgaas
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=20140404154744.GA8549@google.com \
--to=bhelgaas@google.com \
--cc=airlied@redhat.com \
--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;
as well as URLs for NNTP newsgroup(s).