* [PATCH] iommu/arm-smmu-v3: Avoid uninitialized asid in case of error
@ 2024-06-04 18:52 Mostafa Saleh
2024-06-04 18:55 ` Jason Gunthorpe
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mostafa Saleh @ 2024-06-04 18:52 UTC (permalink / raw)
To: will, robin.murphy, linux-arm-kernel, iommu
Cc: linux-kernel, joro, jgg, nicolinc, mshavit, Mostafa Saleh,
Dan Carpenter
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.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes:https://lore.kernel.org/linux-iommu/849e3d77-0a3c-43c4-878d-a0e061c8cd61@moroto.mountain/T/#u
Signed-off-by: Mostafa Saleh <smostafa@google.com>
---
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index ab415e107054..f456bcf1890b 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -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);
--
2.45.1.288.g0e0cd299f1-goog
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] iommu/arm-smmu-v3: Avoid uninitialized asid in case of error
2024-06-04 18:52 [PATCH] iommu/arm-smmu-v3: Avoid uninitialized asid in case of error Mostafa Saleh
@ 2024-06-04 18:55 ` Jason Gunthorpe
2024-06-04 19:09 ` Dan Carpenter
2024-06-05 15:45 ` Will Deacon
2 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2024-06-04 18:55 UTC (permalink / raw)
To: Mostafa Saleh
Cc: will, robin.murphy, linux-arm-kernel, iommu, linux-kernel, joro,
nicolinc, mshavit, Dan Carpenter
On Tue, Jun 04, 2024 at 06:52:18PM +0000, Mostafa Saleh wrote:
> 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.
>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes:https://lore.kernel.org/linux-iommu/849e3d77-0a3c-43c4-878d-a0e061c8cd61@moroto.mountain/T/#u
> Signed-off-by: Mostafa Saleh <smostafa@google.com>
> ---
> 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()")
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
(mind the missing space 'Closes:')
Jason
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] iommu/arm-smmu-v3: Avoid uninitialized asid in case of error
2024-06-04 18:52 [PATCH] iommu/arm-smmu-v3: Avoid uninitialized asid in case of error Mostafa Saleh
2024-06-04 18:55 ` Jason Gunthorpe
@ 2024-06-04 19:09 ` Dan Carpenter
2024-06-05 15:45 ` Will Deacon
2 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2024-06-04 19:09 UTC (permalink / raw)
To: Mostafa Saleh
Cc: will, robin.murphy, linux-arm-kernel, iommu, linux-kernel, joro,
jgg, nicolinc, mshavit
On Tue, Jun 04, 2024 at 06:52:18PM +0000, Mostafa Saleh wrote:
> 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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iommu/arm-smmu-v3: Avoid uninitialized asid in case of error
2024-06-04 18:52 [PATCH] iommu/arm-smmu-v3: Avoid uninitialized asid in case of error Mostafa Saleh
2024-06-04 18:55 ` Jason Gunthorpe
2024-06-04 19:09 ` Dan Carpenter
@ 2024-06-05 15:45 ` Will Deacon
2 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2024-06-05 15:45 UTC (permalink / raw)
To: robin.murphy, linux-arm-kernel, iommu, Mostafa Saleh
Cc: catalin.marinas, kernel-team, Will Deacon, linux-kernel, joro,
nicolinc, mshavit, Dan Carpenter, Jason Gunthorpe
On Tue, 04 Jun 2024 18:52:18 +0000, Mostafa Saleh wrote:
> 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,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-06-05 15:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-04 18:52 [PATCH] iommu/arm-smmu-v3: Avoid uninitialized asid in case of error Mostafa Saleh
2024-06-04 18:55 ` Jason Gunthorpe
2024-06-04 19:09 ` Dan Carpenter
2024-06-05 15:45 ` Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).