Skip to contentSkip to conversation

iommu/arm-smmu-v3: Avoid uninitialized asid in case of error

PATCH Applied Mostafa Saleh 4 participants 4 messages Jun 4, 2024 – Jun 5, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/arm-smmu-v3: Avoid uninitialized asid in case of error

Static checker is complaining about the ASID possibly set uninitialized. This only happens in case of error and this value would be ignored anyway.

A simple fix would be just to initialize the local variable to zero, this path will only be reached on the first attach to a domain where the CD is already initialized to zero.
This avoids having to bloat the function with an error path.

---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +1 -1
index ab415e107054..f456bcf1890b 100644
@@ -2302,7 +2302,7 @@ static int arm_smmu_domain_finalise_s1(struct arm_smmu_device *smmu,
 				       struct arm_smmu_domain *smmu_domain)
 {
 	int ret;
-	u32 asid;
+	u32 asid = 0;
 	struct arm_smmu_ctx_desc *cd = &smmu_domain->cd;
 
 	refcount_set(&cd->refs, 1);
Signature · 1 line
2.45.1.288.g0e0cd299f1-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Mostafa Saleh

Static checker is complaining about the ASID possibly set uninitialized. This only happens in case of error and this value would be ignored anyway.

A simple fix would be just to initialize the local variable to zero, this path will only be reached on the first attach to a domain where the CD is already initialized to zero.
This avoids having to bloat the function with an error path.

Quoted 6 lines
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks this TODO is in my pile of emails :\

Fixes 04905c17f648 ("iommu/arm-smmu-v3: Build the whole CD in arm_smmu_make_s1_cd()")

(mind the missing space 'Closes:')

Jason

#2 lore raw
In reply to Mostafa Saleh
Quoted 4 lines · Mostafa Saleh

A simple fix would be just to initialize the local variable to zero, this path will only be reached on the first attach to a domain where the CD is already initialized to zero.
This avoids having to bloat the function with an error path.

Yep. Since everyone automatically zeroes stack variables these days, this patch doesn't have any impact on runtime at all. It's free. It just silences warning.

regards,
dan carpenter

maintainer Applied
#3 lore raw
In reply to Mostafa Saleh
Quoted 9 lines · Mostafa Saleh

Static checker is complaining about the ASID possibly set uninitialized. This only happens in case of error and this value would be ignored anyway.

A simple fix would be just to initialize the local variable to zero, this path will only be reached on the first attach to a domain where the CD is already initialized to zero.
This avoids having to bloat the function with an error path.

[...]

Applied to will (for-joerg/arm-smmu/updates), thanks!

[1/1] iommu/arm-smmu-v3: Avoid uninitialized asid in case of error

      https://git.kernel.org/will/c/d3867e714831

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev