[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z9l3waI5EdrWmYC3@lizhi-Precision-Tower-5810>
Date: Tue, 18 Mar 2025 09:40:17 -0400
From: Frank Li <Frank.li@....com>
To: Qasim Ijaz <qasdev00@...il.com>
Cc: miquel.raynal@...tlin.com, alexandre.belloni@...tlin.com,
linux-i3c@...ts.infradead.org, imx@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] i3c: master: svc: fix signed/unsigned mismatch in
dynamic address assignment
On Mon, Mar 17, 2025 at 10:15:16AM +0000, Qasim Ijaz wrote:
> svc_i3c_master_do_daa_locked() declares dyn_addr as an unsigned int
> however it initialises it with i3c_master_get_free_addr() which
> returns a signed int type and then attempts to check if dyn_addr is
> less than 0. Unsigned integers cannot be less than 0, so the check
> is essentially redundant. Furthermore i3c_master_get_free_addr()
> could return -ENOMEM which an unsigned int cannot store.
>
> Fix this by capturing the return value of i3c_master_get_free_addr()
> in a signed int ‘dyn_addr_ret’. If that value is negative, return
> an error. Otherwise, assign it to the unsigned int ‘dyn_addr’ once
> we know it’s valid.
>
> Fixes: 4008a74e0f9b ("i3c: master: svc: Fix npcm845 FIFO empty issue")
> Signed-off-by: Qasim Ijaz <qasdev00@...il.com>
> ---
Thank you for your patch, but similar one was already applied
https://lore.kernel.org/linux-i3c/174225158210.1593610.10018812780731849409.b4-ty@bootlin.com/T/#m5120e1c362e7e57f4cab139a45410fde421c2f37
Frank
> drivers/i3c/master/svc-i3c-master.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c
> index f22fb9e75142..eea08f00d7ce 100644
> --- a/drivers/i3c/master/svc-i3c-master.c
> +++ b/drivers/i3c/master/svc-i3c-master.c
> @@ -998,9 +998,10 @@ 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)
> + int dyn_addr_ret = i3c_master_get_free_addr(&master->base, last_addr + 1);
> + if (dyn_addr_ret < 0)
> return -ENOSPC;
> + dyn_addr = dyn_addr_ret;
>
> writel(dyn_addr, master->regs + SVC_I3C_MWDATAB);
>
> --
> 2.39.5
>
Powered by blists - more mailing lists