* [PATCH] iommu/riscv: Fix signedness bug
@ 2026-03-19 18:26 Ethan Tidmore
2026-03-26 14:44 ` Andrew Jones
2026-03-27 8:35 ` Joerg Roedel
0 siblings, 2 replies; 5+ messages in thread
From: Ethan Tidmore @ 2026-03-19 18:26 UTC (permalink / raw)
To: Tomasz Jeznach, Joerg Roedel, Will Deacon, Paul Walmsley,
Palmer Dabbelt, Albert Ou
Cc: Robin Murphy, Alexandre Ghiti, Yaxing Guo, Andrew Jones, iommu,
linux-riscv, linux-kernel, Ethan Tidmore
The function platform_irq_count() returns negative error codes and
iommu->irqs_count is an unsigned integer, so the check
(iommu->irqs_count <= 0) is always impossible.
Make the return value of platform_irq_count() be assigned to ret, check
for error, and then assign iommu->irqs_count to ret.
Detected by Smatch:
drivers/iommu/riscv/iommu-platform.c:119 riscv_iommu_platform_probe() warn:
'iommu->irqs_count' unsigned <= 0
Fixes: 7217cee35aadb ("iommu/riscv: Skip IRQ count check when using MSI interrupts")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
drivers/iommu/riscv/iommu-platform.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/riscv/iommu-platform.c b/drivers/iommu/riscv/iommu-platform.c
index 8f15b06e8499..399ba8fe1b3e 100644
--- a/drivers/iommu/riscv/iommu-platform.c
+++ b/drivers/iommu/riscv/iommu-platform.c
@@ -115,10 +115,13 @@ static int riscv_iommu_platform_probe(struct platform_device *pdev)
fallthrough;
case RISCV_IOMMU_CAPABILITIES_IGS_WSI:
- iommu->irqs_count = platform_irq_count(pdev);
- if (iommu->irqs_count <= 0)
+ ret = platform_irq_count(pdev);
+ if (ret <= 0)
return dev_err_probe(dev, -ENODEV,
"no IRQ resources provided\n");
+
+ iommu->irqs_count = ret;
+
if (iommu->irqs_count > RISCV_IOMMU_INTR_COUNT)
iommu->irqs_count = RISCV_IOMMU_INTR_COUNT;
--
2.53.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iommu/riscv: Fix signedness bug
2026-03-19 18:26 [PATCH] iommu/riscv: Fix signedness bug Ethan Tidmore
@ 2026-03-26 14:44 ` Andrew Jones
2026-03-27 8:35 ` Joerg Roedel
1 sibling, 0 replies; 5+ messages in thread
From: Andrew Jones @ 2026-03-26 14:44 UTC (permalink / raw)
To: Ethan Tidmore
Cc: Tomasz Jeznach, Joerg Roedel, Will Deacon, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Robin Murphy, Alexandre Ghiti,
Yaxing Guo, iommu, linux-riscv, linux-kernel
On Thu, Mar 19, 2026 at 01:26:44PM -0500, Ethan Tidmore wrote:
> The function platform_irq_count() returns negative error codes and
> iommu->irqs_count is an unsigned integer, so the check
> (iommu->irqs_count <= 0) is always impossible.
>
> Make the return value of platform_irq_count() be assigned to ret, check
> for error, and then assign iommu->irqs_count to ret.
>
> Detected by Smatch:
> drivers/iommu/riscv/iommu-platform.c:119 riscv_iommu_platform_probe() warn:
> 'iommu->irqs_count' unsigned <= 0
>
> Fixes: 7217cee35aadb ("iommu/riscv: Skip IRQ count check when using MSI interrupts")
This isn't the correct fixes tag. It should be
Fixes: 5c0ebbd3c6c6 ("iommu/riscv: Add RISC-V IOMMU platform device driver")
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
> ---
> drivers/iommu/riscv/iommu-platform.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iommu/riscv/iommu-platform.c b/drivers/iommu/riscv/iommu-platform.c
> index 8f15b06e8499..399ba8fe1b3e 100644
> --- a/drivers/iommu/riscv/iommu-platform.c
> +++ b/drivers/iommu/riscv/iommu-platform.c
> @@ -115,10 +115,13 @@ static int riscv_iommu_platform_probe(struct platform_device *pdev)
> fallthrough;
>
> case RISCV_IOMMU_CAPABILITIES_IGS_WSI:
> - iommu->irqs_count = platform_irq_count(pdev);
> - if (iommu->irqs_count <= 0)
> + ret = platform_irq_count(pdev);
> + if (ret <= 0)
> return dev_err_probe(dev, -ENODEV,
> "no IRQ resources provided\n");
> +
> + iommu->irqs_count = ret;
> +
> if (iommu->irqs_count > RISCV_IOMMU_INTR_COUNT)
> iommu->irqs_count = RISCV_IOMMU_INTR_COUNT;
>
> --
> 2.53.0
>
Otherwise,
Reviewed-by: Andrew Jones <andrew.jones@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iommu/riscv: Fix signedness bug
2026-03-19 18:26 [PATCH] iommu/riscv: Fix signedness bug Ethan Tidmore
2026-03-26 14:44 ` Andrew Jones
@ 2026-03-27 8:35 ` Joerg Roedel
2026-03-28 16:23 ` Andrew Jones
1 sibling, 1 reply; 5+ messages in thread
From: Joerg Roedel @ 2026-03-27 8:35 UTC (permalink / raw)
To: Ethan Tidmore
Cc: Tomasz Jeznach, Will Deacon, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Robin Murphy, Alexandre Ghiti, Yaxing Guo,
Andrew Jones, iommu, linux-riscv, linux-kernel
On Thu, Mar 19, 2026 at 01:26:44PM -0500, Ethan Tidmore wrote:
> drivers/iommu/riscv/iommu-platform.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
Applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iommu/riscv: Fix signedness bug
2026-03-27 8:35 ` Joerg Roedel
@ 2026-03-28 16:23 ` Andrew Jones
2026-04-01 7:48 ` Joerg Roedel
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Jones @ 2026-03-28 16:23 UTC (permalink / raw)
To: Joerg Roedel
Cc: Ethan Tidmore, Tomasz Jeznach, Will Deacon, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Robin Murphy, Alexandre Ghiti,
Yaxing Guo, iommu, linux-riscv, linux-kernel
On Fri, Mar 27, 2026 at 09:35:05AM +0100, Joerg Roedel wrote:
> On Thu, Mar 19, 2026 at 01:26:44PM -0500, Ethan Tidmore wrote:
> > drivers/iommu/riscv/iommu-platform.c | 7 +++++--
> > 1 file changed, 5 insertions(+), 2 deletions(-)
>
> Applied, thanks.
There's a v2 of this patch with the fixes tag fixed
https://lore.kernel.org/all/20260326175738.750060-1-ethantidmore06@gmail.com/
Thanks,
drew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] iommu/riscv: Fix signedness bug
2026-03-28 16:23 ` Andrew Jones
@ 2026-04-01 7:48 ` Joerg Roedel
0 siblings, 0 replies; 5+ messages in thread
From: Joerg Roedel @ 2026-04-01 7:48 UTC (permalink / raw)
To: Andrew Jones
Cc: Ethan Tidmore, Tomasz Jeznach, Will Deacon, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Robin Murphy, Alexandre Ghiti,
Yaxing Guo, iommu, linux-riscv, linux-kernel
On Sat, Mar 28, 2026 at 11:23:32AM -0500, Andrew Jones wrote:
> On Fri, Mar 27, 2026 at 09:35:05AM +0100, Joerg Roedel wrote:
> > On Thu, Mar 19, 2026 at 01:26:44PM -0500, Ethan Tidmore wrote:
> > > drivers/iommu/riscv/iommu-platform.c | 7 +++++--
> > > 1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > Applied, thanks.
>
> There's a v2 of this patch with the fixes tag fixed
>
> https://lore.kernel.org/all/20260326175738.750060-1-ethantidmore06@gmail.com/
I updated the Fixes tag when applying. So it should be fine, but please double-check.
-Joerg
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-04-01 7:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-19 18:26 [PATCH] iommu/riscv: Fix signedness bug Ethan Tidmore
2026-03-26 14:44 ` Andrew Jones
2026-03-27 8:35 ` Joerg Roedel
2026-03-28 16:23 ` Andrew Jones
2026-04-01 7:48 ` Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®