summaryrefslogtreecommitdiffstats
path: root/arch/x86/pci
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2014-04-25 11:01:08 -0600
committerBjorn Helgaas <bhelgaas@google.com>2014-04-25 11:01:08 -0600
commit0b2d70764bb39242dcc49c0ebd10fcb8258ce5fa (patch)
treebf37d69370a9789abf725e022e2c5c39b40c4a3b /arch/x86/pci
parentc9eaa447e77efe77b7fa4c953bd62de8297fd6c5 (diff)
downloadop-kernel-dev-0b2d70764bb39242dcc49c0ebd10fcb8258ce5fa.zip
op-kernel-dev-0b2d70764bb39242dcc49c0ebd10fcb8258ce5fa.tar.gz
x86/PCI: Fix Broadcom CNB20LE unintended sign extension
In the expression "word1 << 16", word1 starts as u16, but is promoted to a signed int, then sign-extended to resource_size_t, which is probably not what was intended. Cast to resource_size_t to avoid the sign extension. Found by Coverity (CID 138749, 138750). Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'arch/x86/pci')
-rw-r--r--arch/x86/pci/broadcom_bus.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/x86/pci/broadcom_bus.c b/arch/x86/pci/broadcom_bus.c
index 614392c..bb461cf 100644
--- a/arch/x86/pci/broadcom_bus.c
+++ b/arch/x86/pci/broadcom_bus.c
@@ -60,8 +60,8 @@ static void __init cnb20le_res(u8 bus, u8 slot, u8 func)
word1 = read_pci_config_16(bus, slot, func, 0xc4);
word2 = read_pci_config_16(bus, slot, func, 0xc6);
if (word1 != word2) {
- res.start = (word1 << 16) | 0x0000;
- res.end = (word2 << 16) | 0xffff;
+ res.start = ((resource_size_t) word1 << 16) | 0x0000;
+ res.end = ((resource_size_t) word2 << 16) | 0xffff;
res.flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
update_res(info, res.start, res.end, res.flags, 0);
}
OpenPOWER on IntegriCloud