aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorKamalesh Babulal <kamalesh@linux.vnet.ibm.com>2015-06-23 14:07:35 +0530
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-06-24 16:00:03 +1000
commit4608ccb1308a9cc35a43ad0b54c9de1ca1934bd3 (patch)
treee5bf41036fa6d401b856464c2f0c00bd47014168 /core
parent216bd74c7f307390e4f40213e450d29f765d8c13 (diff)
downloadskiboot-4608ccb1308a9cc35a43ad0b54c9de1ca1934bd3.zip
skiboot-4608ccb1308a9cc35a43ad0b54c9de1ca1934bd3.tar.gz
skiboot-4608ccb1308a9cc35a43ad0b54c9de1ca1934bd3.tar.bz2
pci_configure_mps(): Check empty pointer before dereferencing
Re-arrange the code in pci_configure_mps() to avoid dereferencing of in-valid pointer. Fixes Coverity defect#97851. Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core')
-rw-r--r--core/pci.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/core/pci.c b/core/pci.c
index 8f8aeeb..fe23d6c 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -611,14 +611,15 @@ static int pci_configure_mps(struct phb *phb,
uint32_t ecap, mps = phb->mps;
uint16_t val;
+ if (!phb || !pd)
+ return 0;
+
+ mps = phb->mps;
/* If the MPS isn't acceptable one, bail immediately */
if (mps < 128 || mps > 4096)
return 1;
- if (!phb || !pd)
- return 0;
-
- /* PCIe deivce always has MPS capacity */
+ /* PCIe device always has MPS capacity */
if (pd->mps) {
ecap = pci_cap(pd, PCI_CFG_CAP_ID_EXP, false);
mps = ilog2(mps) - 7;