iommu/arm-smmu-v3: Avoid uninitialized asid in case of error
Subsystems (2)
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
@@ -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
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
Reported-by Dan Carpenter <[email protected]>Signed-off-by Mostafa Saleh <[email protected]>--- 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 :\
(mind the missing space 'Closes:')
Jason
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
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