mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dmaengine: loongson: Fix signedness bug
@ 2026-03-18 23:06 Ethan Tidmore
  0 siblings, 0 replies; only message in thread
From: Ethan Tidmore @ 2026-03-18 23:06 UTC (permalink / raw)
  To: Binbin Zhou, Vinod Koul
  Cc: Frank Li, Huacai Chen, dmaengine, linux-kernel, Ethan Tidmore

The function platform_get_irq() returns negative error codes and
lchan->irq is an unsigned integer, so the check (lchan->irq < 0) is
always impossible.

Make the return value of platform_get_irq() be assigned to ret, check
for error, and then assign lchan->irq to ret.

Detected by Smatch:
drivers/dma/loongson/loongson2-apb-cmc-dma.c:677 loongson2_cmc_dma_probe() warn:
unsigned 'lchan->irq' is never less than zero.

Fixes: 1c0028e725f15 ("dmaengine: loongson: New driver for the Loongson Multi-Channel DMA controller")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
 drivers/dma/loongson/loongson2-apb-cmc-dma.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/loongson/loongson2-apb-cmc-dma.c b/drivers/dma/loongson/loongson2-apb-cmc-dma.c
index 1c9a542edc85..2a702de8063c 100644
--- a/drivers/dma/loongson/loongson2-apb-cmc-dma.c
+++ b/drivers/dma/loongson/loongson2-apb-cmc-dma.c
@@ -673,9 +673,11 @@ static int loongson2_cmc_dma_probe(struct platform_device *pdev)
 	for (i = 0; i < nr_chans; i++) {
 		lchan = &lddev->chan[i];
 
-		lchan->irq = platform_get_irq(pdev, i);
-		if (lchan->irq < 0)
-			return lchan->irq;
+		ret = platform_get_irq(pdev, i);
+		if (ret < 0)
+			return ret;
+
+		lchan->irq = ret;
 
 		ret = devm_request_irq(dev, lchan->irq, loongson2_cmc_dma_chan_irq, IRQF_SHARED,
 				       dev_name(chan2dev(lchan)), lchan);
-- 
2.53.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-03-18 23:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-18 23:06 [PATCH] dmaengine: loongson: Fix signedness bug Ethan Tidmore

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®