diff options
| author | Rama Krishna Phani A <rphani@codeaurora.org> | 2019-09-26 15:52:45 +0530 |
|---|---|---|
| committer | Rama Krishna Phani A <rphani@codeaurora.org> | 2019-09-26 18:44:34 +0530 |
| commit | ac54df4a79a59faaa8715ab9ebbe9c0fe97648a7 (patch) | |
| tree | cf8496660e5f7cb6ef419af8d479c398494865e5 | |
| parent | 34b6804ae9302ce8b1f48391cd45110ac723172a (diff) | |
msm: pcie: Add proper check before accessing variables
Base_sel variable is being accessed with out any check.
Add proper check before accessing base_sel variable.
Change-Id: I31232cc0285bc8cc01d8fa4ee7954bf2f766cbce
Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
| -rw-r--r-- | drivers/pci/host/pci-msm.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/pci/host/pci-msm.c b/drivers/pci/host/pci-msm.c index b180e67acafb..98aac17a91b5 100644 --- a/drivers/pci/host/pci-msm.c +++ b/drivers/pci/host/pci-msm.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved. +/* Copyright (c) 2014-2019, 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 @@ -2447,6 +2447,11 @@ 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) { + PCIE_DBG_FS(dev, "Invalid base_sel: 0x%x\n", base_sel); + 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", @@ -2454,10 +2459,7 @@ static void msm_pcie_sel_debug_testcase(struct msm_pcie_dev_t *dev, break; } - if (!base_sel) { - PCIE_DBG_FS(dev, "Invalid base_sel: 0x%x\n", base_sel); - break; - } else if (base_sel - 1 == MSM_PCIE_RES_PARF) { + if (base_sel - 1 == MSM_PCIE_RES_PARF) { pcie_parf_dump(dev); break; } else if (base_sel - 1 == MSM_PCIE_RES_PHY) { |
