From: Bjorn Helgaas <bhelgaas@google.com>
To: "Ira W. Snyder" <iws@ovro.caltech.edu>
Cc: Yinghai Lu <yinghai@kernel.org>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>
Subject: Coverity CIDs 138749, 138750: cnb20le_res() unintended sign extension
Date: Thu, 3 Apr 2014 14:56:26 -0600 [thread overview]
Message-ID: <CAErSpo7uQtRXcxC-9oAS8PJ6Vi3H8Z1fVB2wQR-uxGjyoLDkCQ@mail.gmail.com> (raw)
Coverity complains about unintended sign extension in cnb20le_res() in
arch/x86/pci/broadcom_bus.c here:
60 word1 = read_pci_config_16(bus, slot, func, 0xc4);
61 word2 = read_pci_config_16(bus, slot, func, 0xc6);
62 if (word1 != word2) {
CID 138749 (#1 of 2): Unintended sign extension (SIGN_EXTENSION)
sign_extension: Suspicious implicit sign extension: word1 with type
unsigned short (16 bits, unsigned) is promoted in (word1 << 16) | 0 to
type int (32 bits, signed), then sign-extended to type unsigned long
long (64 bits, unsigned). If (word1 << 16) | 0 is greater than
0x7FFFFFFF, the upper bits of the result will all be 1.
63 res.start = (word1 << 16) | 0x0000;
CID 138750: Unintended sign extension (SIGN_EXTENSION) [select issue]
64 res.end = (word2 << 16) | 0xffff;
65 res.flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
66 update_res(info, res.start, res.end, res.flags, 0);
67 }
Bjorn
next reply other threads:[~2014-04-03 20:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-03 20:56 Bjorn Helgaas [this message]
2014-04-04 0:02 ` Coverity CIDs 138749, 138750: cnb20le_res() unintended sign extension Yinghai Lu
2014-04-04 15:40 ` Bjorn Helgaas
2014-04-25 17:02 ` 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=CAErSpo7uQtRXcxC-9oAS8PJ6Vi3H8Z1fVB2wQR-uxGjyoLDkCQ@mail.gmail.com \
--to=bhelgaas@google.com \
--cc=iws@ovro.caltech.edu \
--cc=linux-pci@vger.kernel.org \
--cc=yinghai@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).