* [PATCH v1 1/1] i3c: master: svc: Fix i3c_master_get_free_addr return check
@ 2025-03-10 2:33 Stanley Chu
2025-03-10 14:34 ` Frank Li
2025-03-17 22:46 ` Alexandre Belloni
0 siblings, 2 replies; 5+ messages in thread
From: Stanley Chu @ 2025-03-10 2:33 UTC (permalink / raw)
To: frank.li, miquel.raynal, alexandre.belloni, linux-i3c
Cc: linux-kernel, tomer.maimon, kwliu, yschu, Dan Carpenter
From: Stanley Chu <yschu@nuvoton.com>
The return value of i3c_master_get_free_addr is assigned to a variable
with wrong type, so it can't be negative. Use a signed integer for the
return value. If the value is negative, break the process and propagate
the error code.
This commit also fixes the uninitialized symbol 'dyn_addr', reported
by Smatch static checker.
Fixes: 4008a74e0f9b ("i3c: master: svc: Fix npcm845 FIFO empty issue")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/all/029e5ac0-5444-4a8e-bca4-cec55950d2b9@stanley.mountain/
Signed-off-by: Stanley Chu <yschu@nuvoton.com>
---
drivers/i3c/master/svc-i3c-master.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
index f22fb9e75142..1d1f351b9a85 100644
--- a/drivers/i3c/master/svc-i3c-master.c
+++ b/drivers/i3c/master/svc-i3c-master.c
@@ -940,7 +940,7 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master,
u8 *addrs, unsigned int *count)
{
u64 prov_id[SVC_I3C_MAX_DEVS] = {}, nacking_prov_id = 0;
- unsigned int dev_nb = 0, last_addr = 0, dyn_addr;
+ unsigned int dev_nb = 0, last_addr = 0, dyn_addr = 0;
u32 reg;
int ret, i;
@@ -998,10 +998,11 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master,
* filling within a few hundred nanoseconds, which is significantly
* faster compared to the 64 SCL clock cycles.
*/
- dyn_addr = i3c_master_get_free_addr(&master->base, last_addr + 1);
- if (dyn_addr < 0)
- return -ENOSPC;
+ ret = i3c_master_get_free_addr(&master->base, last_addr + 1);
+ if (ret < 0)
+ break;
+ dyn_addr = ret;
writel(dyn_addr, master->regs + SVC_I3C_MWDATAB);
/*
--
2.34.1
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] i3c: master: svc: Fix i3c_master_get_free_addr return check
2025-03-10 2:33 [PATCH v1 1/1] i3c: master: svc: Fix i3c_master_get_free_addr return check Stanley Chu
@ 2025-03-10 14:34 ` Frank Li
2025-03-17 22:46 ` Alexandre Belloni
1 sibling, 0 replies; 5+ messages in thread
From: Frank Li @ 2025-03-10 14:34 UTC (permalink / raw)
To: Stanley Chu
Cc: miquel.raynal, alexandre.belloni, linux-i3c, linux-kernel,
tomer.maimon, kwliu, yschu, Dan Carpenter
On Mon, Mar 10, 2025 at 10:33:04AM +0800, Stanley Chu wrote:
> From: Stanley Chu <yschu@nuvoton.com>
>
> The return value of i3c_master_get_free_addr is assigned to a variable
> with wrong type, so it can't be negative. Use a signed integer for the
> return value. If the value is negative, break the process and propagate
> the error code.
>
> This commit also fixes the uninitialized symbol 'dyn_addr', reported
> by Smatch static checker.
>
> Fixes: 4008a74e0f9b ("i3c: master: svc: Fix npcm845 FIFO empty issue")
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/all/029e5ac0-5444-4a8e-bca4-cec55950d2b9@stanley.mountain/
> Signed-off-by: Stanley Chu <yschu@nuvoton.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/i3c/master/svc-i3c-master.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> index f22fb9e75142..1d1f351b9a85 100644
> --- a/drivers/i3c/master/svc-i3c-master.c
> +++ b/drivers/i3c/master/svc-i3c-master.c
> @@ -940,7 +940,7 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master,
> u8 *addrs, unsigned int *count)
> {
> u64 prov_id[SVC_I3C_MAX_DEVS] = {}, nacking_prov_id = 0;
> - unsigned int dev_nb = 0, last_addr = 0, dyn_addr;
> + unsigned int dev_nb = 0, last_addr = 0, dyn_addr = 0;
> u32 reg;
> int ret, i;
>
> @@ -998,10 +998,11 @@ static int svc_i3c_master_do_daa_locked(struct svc_i3c_master *master,
> * filling within a few hundred nanoseconds, which is significantly
> * faster compared to the 64 SCL clock cycles.
> */
> - dyn_addr = i3c_master_get_free_addr(&master->base, last_addr + 1);
> - if (dyn_addr < 0)
> - return -ENOSPC;
> + ret = i3c_master_get_free_addr(&master->base, last_addr + 1);
> + if (ret < 0)
> + break;
>
> + dyn_addr = ret;
> writel(dyn_addr, master->regs + SVC_I3C_MWDATAB);
>
> /*
> --
> 2.34.1
>
>
> --
> linux-i3c mailing list
> linux-i3c@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-i3c
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] i3c: master: svc: Fix i3c_master_get_free_addr return check
2025-03-10 2:33 [PATCH v1 1/1] i3c: master: svc: Fix i3c_master_get_free_addr return check Stanley Chu
2025-03-10 14:34 ` Frank Li
@ 2025-03-17 22:46 ` Alexandre Belloni
2025-03-18 14:51 ` Qasim Ijaz
1 sibling, 1 reply; 5+ messages in thread
From: Alexandre Belloni @ 2025-03-17 22:46 UTC (permalink / raw)
To: frank.li, miquel.raynal, linux-i3c, Stanley Chu
Cc: linux-kernel, tomer.maimon, kwliu, yschu, Dan Carpenter
On Mon, 10 Mar 2025 10:33:04 +0800, Stanley Chu wrote:
> The return value of i3c_master_get_free_addr is assigned to a variable
> with wrong type, so it can't be negative. Use a signed integer for the
> return value. If the value is negative, break the process and propagate
> the error code.
>
> This commit also fixes the uninitialized symbol 'dyn_addr', reported
> by Smatch static checker.
>
> [...]
Applied, thanks!
[1/1] i3c: master: svc: Fix i3c_master_get_free_addr return check
https://git.kernel.org/abelloni/c/d6cb667b8e15
Best regards,
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] i3c: master: svc: Fix i3c_master_get_free_addr return check
2025-03-17 22:46 ` Alexandre Belloni
@ 2025-03-18 14:51 ` Qasim Ijaz
2025-03-18 15:58 ` Alexandre Belloni
0 siblings, 1 reply; 5+ messages in thread
From: Qasim Ijaz @ 2025-03-18 14:51 UTC (permalink / raw)
To: Alexandre Belloni
Cc: miquel.raynal, Frank.Li, alexandre.belloni, linux-i3c, imx,
linux-kernel
On Mon, Mar 17, 2025 at 11:46:29PM +0100, Alexandre Belloni wrote:
> On Mon, 10 Mar 2025 10:33:04 +0800, Stanley Chu wrote:
> > The return value of i3c_master_get_free_addr is assigned to a variable
> > with wrong type, so it can't be negative. Use a signed integer for the
> > return value. If the value is negative, break the process and propagate
> > the error code.
> >
> > This commit also fixes the uninitialized symbol 'dyn_addr', reported
> > by Smatch static checker.
> >
> > [...]
>
> Applied, thanks!
>
> [1/1] i3c: master: svc: Fix i3c_master_get_free_addr return check
> https://git.kernel.org/abelloni/c/d6cb667b8e15
>
> Best regards,
>
> --
> Alexandre Belloni, co-owner and COO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
Hi Alexandre,
I sent a fix for this issue on the 9th March, which is before the patch
Stanley sent which was sent on the 10th March.
You can view my orignal patch here:
https://lore.kernel.org/all/20250309164314.15039-1-qasdev00@gmail.com/
Thanks
Qasim
>
> --
> linux-i3c mailing list
> linux-i3c@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-i3c
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] i3c: master: svc: Fix i3c_master_get_free_addr return check
2025-03-18 14:51 ` Qasim Ijaz
@ 2025-03-18 15:58 ` Alexandre Belloni
0 siblings, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2025-03-18 15:58 UTC (permalink / raw)
To: Qasim Ijaz; +Cc: miquel.raynal, Frank.Li, linux-i3c, imx, linux-kernel
On 18/03/2025 14:51:49+0000, Qasim Ijaz wrote:
> On Mon, Mar 17, 2025 at 11:46:29PM +0100, Alexandre Belloni wrote:
> > On Mon, 10 Mar 2025 10:33:04 +0800, Stanley Chu wrote:
> > > The return value of i3c_master_get_free_addr is assigned to a variable
> > > with wrong type, so it can't be negative. Use a signed integer for the
> > > return value. If the value is negative, break the process and propagate
> > > the error code.
> > >
> > > This commit also fixes the uninitialized symbol 'dyn_addr', reported
> > > by Smatch static checker.
> > >
> > > [...]
> >
> > Applied, thanks!
> >
> > [1/1] i3c: master: svc: Fix i3c_master_get_free_addr return check
> > https://git.kernel.org/abelloni/c/d6cb667b8e15
> >
> > Best regards,
> >
> > --
> > Alexandre Belloni, co-owner and COO, Bootlin
> > Embedded Linux and Kernel engineering
> > https://bootlin.com
>
> Hi Alexandre,
>
> I sent a fix for this issue on the 9th March, which is before the patch
> Stanley sent which was sent on the 10th March.
>
> You can view my orignal patch here:
>
> https://lore.kernel.org/all/20250309164314.15039-1-qasdev00@gmail.com/
>
The issue is that you then resent the patch with the same topic which
superseded your original patch. But the resend was missing a blank line
so I could not apply it immediately and I later applied the other one.
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-03-18 15:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-10 2:33 [PATCH v1 1/1] i3c: master: svc: Fix i3c_master_get_free_addr return check Stanley Chu
2025-03-10 14:34 ` Frank Li
2025-03-17 22:46 ` Alexandre Belloni
2025-03-18 14:51 ` Qasim Ijaz
2025-03-18 15:58 ` Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).