public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] i2c: at91: Initialize dma_buf in at91_twi_xfer()
@ 2022-05-05 15:27 Nathan Chancellor
  2022-05-05 15:38 ` Michael Walle
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Nathan Chancellor @ 2022-05-05 15:27 UTC (permalink / raw)
  To: Codrin Ciubotariu, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Wolfram Sang, Michael Walle
  Cc: Nick Desaulniers, Tom Rix, linux-i2c, linux-arm-kernel,
	linux-kernel, llvm, Nathan Chancellor

Clang warns:

  drivers/i2c/busses/i2c-at91-master.c:707:6: warning: variable 'dma_buf' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
          if (dev->use_dma) {
              ^~~~~~~~~~~~
  drivers/i2c/busses/i2c-at91-master.c:717:27: note: uninitialized use occurs here
          i2c_put_dma_safe_msg_buf(dma_buf, m_start, !ret);
                                   ^~~~~~~

Initialize dma_buf to NULL, as i2c_put_dma_safe_msg_buf() is a no-op
when the first argument is NULL, which will work for the !dev->use_dma
case.

Fixes: 03fbb903c8bf ("i2c: at91: use dma safe buffers")
Link: https://github.com/ClangBuiltLinux/linux/issues/1629
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/i2c/busses/i2c-at91-master.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-at91-master.c b/drivers/i2c/busses/i2c-at91-master.c
index 5eca3b3bb609..c0c35785a0dc 100644
--- a/drivers/i2c/busses/i2c-at91-master.c
+++ b/drivers/i2c/busses/i2c-at91-master.c
@@ -656,7 +656,7 @@ static int at91_twi_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, int num)
 	unsigned int_addr_flag = 0;
 	struct i2c_msg *m_start = msg;
 	bool is_read;
-	u8 *dma_buf;
+	u8 *dma_buf = NULL;
 
 	dev_dbg(&adap->dev, "at91_xfer: processing %d messages:\n", num);
 

base-commit: a181b8d187319bf265a2019ddde856a3d2f107a6
-- 
2.36.0


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

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

end of thread, other threads:[~2022-05-14 21:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-05 15:27 [PATCH] i2c: at91: Initialize dma_buf in at91_twi_xfer() Nathan Chancellor
2022-05-05 15:38 ` Michael Walle
2022-05-13 16:50 ` Nathan Chancellor
2022-05-14 13:42 ` Wolfram Sang
2022-05-14 21:05   ` Nathan Chancellor

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