All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: lizhi.hou@amd.com, brian.xu@amd.com, raj.kumar.rampelli@amd.com,
	 vkoul@kernel.org, jankul@alatek.krakow.pl
Cc: dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	 llvm@lists.linux.dev, patches@lists.linux.dev,
	 Nathan Chancellor <nathan@kernel.org>
Subject: [PATCH 2/2] dmaengine: xilinx: xdma: Fix initialization location of desc in xdma_channel_isr()
Date: Fri, 22 Dec 2023 11:06:45 -0700	[thread overview]
Message-ID: <20231222-dma-xilinx-xdma-clang-fixes-v1-2-84a18ff184d2@kernel.org> (raw)
In-Reply-To: <20231222-dma-xilinx-xdma-clang-fixes-v1-0-84a18ff184d2@kernel.org>

Clang warns (or errors with CONFIG_WERROR=y):

  drivers/dma/xilinx/xdma.c:894:3: error: variable 'desc' is uninitialized when used here [-Werror,-Wuninitialized]
    894 |                 desc->error = true;
        |                 ^~~~

The initialization of desc was moved too far forward, move it back so
that this assignment does not result in a potential crash at runtime
while clearing up the warning.

Closes: https://github.com/ClangBuiltLinux/linux/issues/1972
Fixes: 2f8f90cd2f8d ("dmaengine: xilinx: xdma: Implement interleaved DMA transfers")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/dma/xilinx/xdma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/xilinx/xdma.c b/drivers/dma/xilinx/xdma.c
index d5b9fc3fd955..ee595d1ebc63 100644
--- a/drivers/dma/xilinx/xdma.c
+++ b/drivers/dma/xilinx/xdma.c
@@ -888,6 +888,8 @@ static irqreturn_t xdma_channel_isr(int irq, void *dev_id)
 	if (ret)
 		goto out;
 
+	desc = to_xdma_desc(vd);
+
 	st &= XDMA_CHAN_STATUS_MASK;
 	if ((st & XDMA_CHAN_ERROR_MASK) ||
 	    !(st & (CHAN_CTRL_IE_DESC_COMPLETED | CHAN_CTRL_IE_DESC_STOPPED))) {
@@ -901,7 +903,6 @@ static irqreturn_t xdma_channel_isr(int irq, void *dev_id)
 	if (ret)
 		goto out;
 
-	desc = to_xdma_desc(vd);
 	if (desc->interleaved_dma) {
 		xchan->busy = false;
 		desc->completed_desc_num += complete_desc_num;

-- 
2.43.0


WARNING: multiple messages have this Message-ID (diff)
From: Nathan Chancellor <nathan@kernel.org>
To: lizhi.hou@amd.com, brian.xu@amd.com, raj.kumar.rampelli@amd.com,
	 vkoul@kernel.org, jankul@alatek.krakow.pl
Cc: dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	 llvm@lists.linux.dev, patches@lists.linux.dev,
	 Nathan Chancellor <nathan@kernel.org>
Subject: [PATCH 2/2] dmaengine: xilinx: xdma: Fix initialization location of desc in xdma_channel_isr()
Date: Fri, 22 Dec 2023 11:06:45 -0700	[thread overview]
Message-ID: <20231222-dma-xilinx-xdma-clang-fixes-v1-2-84a18ff184d2@kernel.org> (raw)
In-Reply-To: <20231222-dma-xilinx-xdma-clang-fixes-v1-0-84a18ff184d2@kernel.org>

Clang warns (or errors with CONFIG_WERROR=y):

  drivers/dma/xilinx/xdma.c:894:3: error: variable 'desc' is uninitialized when used here [-Werror,-Wuninitialized]
    894 |                 desc->error = true;
        |                 ^~~~

The initialization of desc was moved too far forward, move it back so
that this assignment does not result in a potential crash at runtime
while clearing up the warning.

Closes: https://github.com/ClangBuiltLinux/linux/issues/1972
Fixes: 2f8f90cd2f8d ("dmaengine: xilinx: xdma: Implement interleaved DMA transfers")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/dma/xilinx/xdma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/xilinx/xdma.c b/drivers/dma/xilinx/xdma.c
index d5b9fc3fd955..ee595d1ebc63 100644
--- a/drivers/dma/xilinx/xdma.c
+++ b/drivers/dma/xilinx/xdma.c
@@ -888,6 +888,8 @@ static irqreturn_t xdma_channel_isr(int irq, void *dev_id)
 	if (ret)
 		goto out;
 
+	desc = to_xdma_desc(vd);
+
 	st &= XDMA_CHAN_STATUS_MASK;
 	if ((st & XDMA_CHAN_ERROR_MASK) ||
 	    !(st & (CHAN_CTRL_IE_DESC_COMPLETED | CHAN_CTRL_IE_DESC_STOPPED))) {
@@ -901,7 +903,6 @@ static irqreturn_t xdma_channel_isr(int irq, void *dev_id)
 	if (ret)
 		goto out;
 
-	desc = to_xdma_desc(vd);
 	if (desc->interleaved_dma) {
 		xchan->busy = false;
 		desc->completed_desc_num += complete_desc_num;

-- 
2.43.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-12-22 18:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-22 18:06 [PATCH 0/2] dmaengine: xilinx: xdma: Fix two clang warnings Nathan Chancellor
2023-12-22 18:06 ` Nathan Chancellor
2023-12-22 18:06 ` [PATCH 1/2] dmaengine: xilinx: xdma: Fix operator precedence in xdma_prep_interleaved_dma() Nathan Chancellor
2023-12-22 18:06   ` Nathan Chancellor
2023-12-22 18:06 ` Nathan Chancellor [this message]
2023-12-22 18:06   ` [PATCH 2/2] dmaengine: xilinx: xdma: Fix initialization location of desc in xdma_channel_isr() Nathan Chancellor
2023-12-22 22:43 ` [PATCH 0/2] dmaengine: xilinx: xdma: Fix two clang warnings Jan Kuliga
2023-12-22 22:43   ` Jan Kuliga
2024-01-19 12:50 ` Vinod Koul
2024-01-19 12:50   ` Vinod Koul

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=20231222-dma-xilinx-xdma-clang-fixes-v1-2-84a18ff184d2@kernel.org \
    --to=nathan@kernel.org \
    --cc=brian.xu@amd.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=jankul@alatek.krakow.pl \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=lizhi.hou@amd.com \
    --cc=llvm@lists.linux.dev \
    --cc=patches@lists.linux.dev \
    --cc=raj.kumar.rampelli@amd.com \
    --cc=vkoul@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.