Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7eea87ce authored by Rama Krishna Phani A's avatar Rama Krishna Phani A
Browse files

msm: pcie: Use local variable for manipulation



There is a chance that wr_offset can be modified to
an arbitrary value as it is a global variable. Have
a local copy of this value and use it for further
manipulation.

Change-Id: If3b76a0dd95e81bd057d89626818c72405f91d65
Signed-off-by: default avatarRama Krishna Phani A <rphani@codeaurora.org>
parent a8e92fae
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -2067,6 +2067,7 @@ static void msm_pcie_sel_debug_testcase(struct msm_pcie_dev_t *dev,
	u32 ep_l1sub_cap_reg1_offset = 0;
	u32 ep_link_ctrlstts_offset = 0;
	u32 ep_dev_ctrl2stts2_offset = 0;
	u32 wr_ofst = 0;

	if (testcase >= 5 && testcase <= 10) {
		current_offset =
@@ -2428,22 +2429,24 @@ static void msm_pcie_sel_debug_testcase(struct msm_pcie_dev_t *dev,
			break;
		}

		wr_ofst = wr_offset;

		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,
			dev->res[base_sel - 1].base,
			wr_offset, wr_mask, wr_value);
			wr_ofst, wr_mask, wr_value);

		base_sel_size = resource_size(dev->res[base_sel - 1].resource);

		if (wr_offset >  base_sel_size - 4 ||
			msm_pcie_check_align(dev, wr_offset))
		if (wr_ofst >  base_sel_size - 4 ||
			msm_pcie_check_align(dev, wr_ofst))
			PCIE_DBG_FS(dev,
				"PCIe: RC%d: Invalid wr_offset: 0x%x. wr_offset should be no more than 0x%x\n",
				dev->rc_idx, wr_offset, base_sel_size - 4);
				dev->rc_idx, wr_ofst, base_sel_size - 4);
		else
			msm_pcie_write_reg_field(dev->res[base_sel - 1].base,
				wr_offset, wr_mask, wr_value);
				wr_ofst, wr_mask, wr_value);

		break;
	case 13: /* dump all registers of base_sel */