From: Frank Li <Frank.li@nxp.com>
To: Stanley Chu <stanley.chuys@gmail.com>
Cc: miquel.raynal@bootlin.com, alexandre.belloni@bootlin.com,
linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org,
tomer.maimon@nuvoton.com, kwliu@nuvoton.com, yschu@nuvoton.com,
Dan Carpenter <dan.carpenter@linaro.org>
Subject: Re: [PATCH v1 1/1] i3c: master: svc: Fix i3c_master_get_free_addr return check
Date: Mon, 10 Mar 2025 10:34:30 -0400 [thread overview]
Message-ID: <Z874dh9lV7P+GpkM@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20250310023304.2335792-1-yschu@nuvoton.com>
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
next prev parent reply other threads:[~2025-03-10 14:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-10 2:33 Stanley Chu
2025-03-10 14:34 ` Frank Li [this message]
2025-03-17 22:46 ` Alexandre Belloni
2025-03-18 14:51 ` Qasim Ijaz
2025-03-18 15:58 ` Alexandre Belloni
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=Z874dh9lV7P+GpkM@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=alexandre.belloni@bootlin.com \
--cc=dan.carpenter@linaro.org \
--cc=kwliu@nuvoton.com \
--cc=linux-i3c@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=stanley.chuys@gmail.com \
--cc=tomer.maimon@nuvoton.com \
--cc=yschu@nuvoton.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®