public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] iommu/riscv: Fix signedness bug
@ 2026-03-26 17:57 Ethan Tidmore
  2026-04-30  3:25 ` patchwork-bot+linux-riscv
  0 siblings, 1 reply; 2+ messages in thread
From: Ethan Tidmore @ 2026-03-26 17:57 UTC (permalink / raw)
  To: Tomasz Jeznach, Joerg Roedel, Will Deacon, Paul Walmsley,
	Palmer Dabbelt, Albert Ou
  Cc: Robin Murphy, Alexandre Ghiti, Nick Kossifidis, Sebastien Boeuf,
	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: 5c0ebbd3c6c6 ("iommu/riscv: Add RISC-V IOMMU platform device driver")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
Reviewed-by: Andrew Jones <andrew.jones@oss.qualcomm.com>
---
v2: 
- Add correct Fixes tag.
- Add RB tag from Andrew Jones

 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 related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] iommu/riscv: Fix signedness bug
  2026-03-26 17:57 [PATCH v2] iommu/riscv: Fix signedness bug Ethan Tidmore
@ 2026-04-30  3:25 ` patchwork-bot+linux-riscv
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+linux-riscv @ 2026-04-30  3:25 UTC (permalink / raw)
  To: Ethan Tidmore
  Cc: linux-riscv, tjeznach, joro, will, pjw, palmer, aou, robin.murphy,
	alex, mick, seb, andrew.jones, iommu, linux-kernel

Hello:

This patch was applied to riscv/linux.git (fixes)
by Joerg Roedel <joerg.roedel@amd.com>:

On Thu, 26 Mar 2026 12:57:38 -0500 you 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.
> 
> [...]

Here is the summary with links:
  - [v2] iommu/riscv: Fix signedness bug
    https://git.kernel.org/riscv/c/553a127cb665

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-30  3:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-26 17:57 [PATCH v2] iommu/riscv: Fix signedness bug Ethan Tidmore
2026-04-30  3:25 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox