public inbox for dmaengine@vger.kernel.org
 help / color / mirror / Atom feed
From: Ethan Tidmore <ethantidmore06@gmail.com>
To: Binbin Zhou <zhoubinbin@loongson.cn>, Vinod Koul <vkoul@kernel.org>
Cc: Frank Li <Frank.Li@kernel.org>,
	Huacai Chen <chenhuacai@kernel.org>,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ethan Tidmore <ethantidmore06@gmail.com>
Subject: [PATCH] dmaengine: loongson: Fix signedness bug
Date: Wed, 18 Mar 2026 18:06:23 -0500	[thread overview]
Message-ID: <20260318230623.1084926-1-ethantidmore06@gmail.com> (raw)

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


                 reply	other threads:[~2026-03-18 23:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260318230623.1084926-1-ethantidmore06@gmail.com \
    --to=ethantidmore06@gmail.com \
    --cc=Frank.Li@kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vkoul@kernel.org \
    --cc=zhoubinbin@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox