i3c: master: svc: Fix i3c_master_get_free_addr return check
Subsystems (3)
PATCH 1/1 i3c: master: svc: Fix i3c_master_get_free_addr return check
From: Stanley Chu <[email protected]>
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.
--- drivers/i3c/master/svc-i3c-master.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/i3c/master/svc-i3c-master.c +5 -4
@@ -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 );/*
Signature · 1 line
2.34.1
Quoted 7 lines · Stanley Chu
From: Stanley Chu <[email protected]>
The return value of
i3c_master_get_free_addris 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.
Quoted 8 lines
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 <[email protected]>Signed-off-by Stanley Chu <[email protected]>---
Quoted 39 lines
drivers/i3c/master/svc-i3c-master.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/i3c/master/svc-i3c-master.c +5
-5@@ -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
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
Quoted 9 lines · Stanley Chu
The return value of
i3c_master_get_free_addris 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,
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Quoted 9 lines · Alexandre Belloni
Quoted 8 lines · Stanley Chu
The return value of
i3c_master_get_free_addris 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.
Quoted 13 lines
Quoted 1 line
[...]
Applied, thanks!
[1/1] i3c: master: svc: Fix
i3c_master_get_free_addrreturn checkhttps://git.kernel.org/abelloni/c/d6cb667b8e15Best regards,
Signature · 3 lines
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/[email protected]/
Thanks
Qasim
Quoted 5 lines
Signature · 4 lines
-- linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
Alexandre Belloni
maintainerQuoted 24 lines · Qasim Ijaz
Quoted 9 lines · Alexandre Belloni
Quoted 8 lines · Stanley Chu
The return value of
i3c_master_get_free_addris 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.Quoted 13 lines
Quoted 1 line
[...]
Applied, thanks!
[1/1] i3c: master: svc: Fix
i3c_master_get_free_addrreturn checkhttps://git.kernel.org/abelloni/c/d6cb667b8e15Best regards,
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Quoted 9 lines
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:
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.
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com