Commit 362dada9 authored by Zhang Zekun's avatar Zhang Zekun
Browse files

iommu/arm-smmu-v3: fix using uninitialized or unchecked symbol

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9EEIG



--------------------------------------

In arm_smmu_ecmdq_probe(), the parameter pre_addr is used in the loop
but it is not initialed yet. Also, the parameter "ecmdq" is used before
check if it is NULL.

Signed-off-by: default avatarZhang Zekun <zhangzekun11@huawei.com>
parent 0c8d7c88
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -4078,7 +4078,7 @@ static int arm_smmu_ecmdq_probe(struct arm_smmu_device *smmu)
	int ret, cpu;
	u32 i, nump, numq, gap;
	u32 reg, shift_increment;
	u64 addr, smmu_dma_base;
	u64 addr, smmu_dma_base, val, pre_addr;
	void __iomem *cp_regs, *cp_base;

	/* IDR6 */
@@ -4096,8 +4096,6 @@ static int arm_smmu_ecmdq_probe(struct arm_smmu_device *smmu)
		return -ENOMEM;

	for (i = 0; i < nump; i++) {
		u64 val, pre_addr;

		val = readq_relaxed(cp_regs + 32 * i);
		if (!(val & ECMDQ_CP_PRESET)) {
			iounmap(cp_regs);
@@ -4137,7 +4135,6 @@ static int arm_smmu_ecmdq_probe(struct arm_smmu_device *smmu)
		struct arm_smmu_queue *q;

		ecmdq = *per_cpu_ptr(smmu->ecmdqs, cpu);
		q = &ecmdq->cmdq.q;

		/*
		 * The boot option "maxcpus=" can limit the number of online
@@ -4150,6 +4147,8 @@ static int arm_smmu_ecmdq_probe(struct arm_smmu_device *smmu)
		 */
		if (!ecmdq || (ecmdq != per_cpu_ptr(smmu->ecmdq, cpu)))
			continue;

		q = &ecmdq->cmdq.q;
		ecmdq->base = cp_base + addr;

		q->llq.max_n_shift = ECMDQ_MAX_SZ_SHIFT + shift_increment;