ANDROID: KVM: arm64: iommu: Avoid use of uninitialized variable in smmu_map_pages
When the while condition is first evaluated, the variable named ret may
be used uninitialized. Additionally, it is not necessary to make it part
of the while condition, because the only place where this variable is
changed is an assignment after the call to map_pages, and there is
already an if statement that checks its value.
Bug: 394152442
Fixes: a737b7d0e721 ("ANDROID: KVM: arm64: iommu: Reduce the logic in generic code")
Change-Id: I3a214f5ac424bc13b2443097cd6a2a05a6397393
Signed-off-by: Daniel Mentz <danielmentz@google.com>
Signed-off-by: Mostafa Saleh <smostafa@google.com>
This commit is contained in:
committed by
Mostafa Saleh
parent
ca30cfa77a
commit
3ded8a3190
@@ -1425,7 +1425,7 @@ static int smmu_map_pages(struct kvm_hyp_iommu_domain *domain, unsigned long iov
|
||||
{
|
||||
size_t mapped;
|
||||
size_t granule;
|
||||
int ret;
|
||||
int ret = 0;
|
||||
struct hyp_arm_smmu_v3_domain *smmu_domain = domain->priv;
|
||||
struct io_pgtable *pgtable = smmu_domain->pgtable;
|
||||
|
||||
@@ -1437,7 +1437,7 @@ static int smmu_map_pages(struct kvm_hyp_iommu_domain *domain, unsigned long iov
|
||||
return -EINVAL;
|
||||
|
||||
hyp_spin_lock(&smmu_domain->pgt_lock);
|
||||
while (pgcount && !ret) {
|
||||
while (pgcount) {
|
||||
mapped = 0;
|
||||
ret = pgtable->ops.map_pages(&pgtable->ops, iova, paddr,
|
||||
pgsize, pgcount, prot, 0, &mapped);
|
||||
@@ -1453,7 +1453,7 @@ static int smmu_map_pages(struct kvm_hyp_iommu_domain *domain, unsigned long iov
|
||||
}
|
||||
hyp_spin_unlock(&smmu_domain->pgt_lock);
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static size_t smmu_unmap_pages(struct kvm_hyp_iommu_domain *domain, unsigned long iova,
|
||||
|
||||
Reference in New Issue
Block a user