2022-05-05 23:08:38

by Nathan Chancellor

[permalink] [raw]
Subject: [PATCH] i2c: at91: Initialize dma_buf in at91_twi_xfer()

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 <[email protected]>
---
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



2022-05-09 04:49:31

by Michael Walle

[permalink] [raw]
Subject: Re: [PATCH] i2c: at91: Initialize dma_buf in at91_twi_xfer()

Am 2022-05-05 17:27, schrieb 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 <[email protected]>

Thanks for fixing.

Reviewed-by: Michael Walle <[email protected]>

-michael

2022-05-14 02:17:42

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH] i2c: at91: Initialize dma_buf in at91_twi_xfer()

Ping? This is a pretty obvious fix and this warning turns into an error
with CONFIG_WERROR so some of our -next builds have been broken for over
a week now.

On Thu, May 05, 2022 at 08:27:38AM -0700, Nathan Chancellor wrote:
> 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 <[email protected]>
> ---
> 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
>
>

2022-05-14 14:03:40

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH] i2c: at91: Initialize dma_buf in at91_twi_xfer()

On Thu, May 05, 2022 at 08:27:38AM -0700, Nathan Chancellor wrote:
> 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 <[email protected]>

Applied to for-next, thanks!


Attachments:
(No filename) (880.00 B)
signature.asc (849.00 B)
Download all attachments

2022-05-16 15:22:10

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH] i2c: at91: Initialize dma_buf in at91_twi_xfer()

On Sat, May 14, 2022 at 03:42:08PM +0200, Wolfram Sang wrote:
> On Thu, May 05, 2022 at 08:27:38AM -0700, Nathan Chancellor wrote:
> > 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 <[email protected]>
>
> Applied to for-next, thanks!
>

Thank you!

Cheers,
Nathan