summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRama Krishna Phani A <rphani@codeaurora.org>2018-03-21 15:37:56 +0530
committerRama Krishna Phani A <rphani@codeaurora.org>2018-03-22 16:18:45 +0530
commit51df7d76f7385f3323bae92ab2f6c91bcec69936 (patch)
tree23cd6fecc61b94ba31c0cbd0074d59b886c67f88
parenta337c17cebeadebddd57cfae9d7953567969be06 (diff)
msm: pcie: Add proper check before accessing variables
Add proper check before accessing variables. Change-Id: Idb4aec6e276d7c82a4311be733fcb13b875ae6c8 Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
-rw-r--r--drivers/pci/host/pci-msm.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/pci/host/pci-msm.c b/drivers/pci/host/pci-msm.c
index 0ecf64f4afe9..e01ea16d8db2 100644
--- a/drivers/pci/host/pci-msm.c
+++ b/drivers/pci/host/pci-msm.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -2421,6 +2421,13 @@ static void msm_pcie_sel_debug_testcase(struct msm_pcie_dev_t *dev,
break;
}
+ if (((base_sel - 1) >= MSM_PCIE_MAX_RES) ||
+ (!dev->res[base_sel - 1].resource)) {
+ PCIE_DBG_FS(dev, "PCIe: RC%d Resource does not exist\n",
+ dev->rc_idx);
+ break;
+ }
+
PCIE_DBG_FS(dev,
"base: %s: 0x%p\nwr_offset: 0x%x\nwr_mask: 0x%x\nwr_value: 0x%x\n",
dev->res[base_sel - 1].name,
@@ -2440,6 +2447,13 @@ static void msm_pcie_sel_debug_testcase(struct msm_pcie_dev_t *dev,
break;
case 13: /* dump all registers of base_sel */
+ if (((base_sel - 1) >= MSM_PCIE_MAX_RES) ||
+ (!dev->res[base_sel - 1].resource)) {
+ PCIE_DBG_FS(dev, "PCIe: RC%d Resource does not exist\n",
+ dev->rc_idx);
+ break;
+ }
+
if (!base_sel) {
PCIE_DBG_FS(dev, "Invalid base_sel: 0x%x\n", base_sel);
break;