[PATCH] cmd: i2c: fix coverity issue

Heiko Schocher hs at denx.de
Mon Aug 4 11:43:29 CEST 2025


coverity scan reported issue:
** CID 583415:       Integer handling issues  (INTEGER_OVERFLOW)
/cmd/i2c.c: 369           in do_i2c_write()

change the length variable into type int.

Signed-off-by: Heiko Schocher <hs at denx.de>
---
azure build:
https://dev.azure.com/hs0298/hs/_build/results?buildId=183&view=results

 cmd/i2c.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cmd/i2c.c b/cmd/i2c.c
index f0aae93073f..e021067e68a 100644
--- a/cmd/i2c.c
+++ b/cmd/i2c.c
@@ -299,7 +299,8 @@ static int do_i2c_write(struct cmd_tbl *cmdtp, int flag, int argc,
 			char *const argv[])
 {
 	uint	chip;
-	uint	devaddr, length;
+	uint	devaddr;
+	int length;
 	int alen;
 	u_char  *memaddr;
 	int ret;
-- 
2.20.1

base-commit: ae5711f881100f856ead1e76832c32b92dba93c7
branch: i2c-coverity-issue-v1


More information about the U-Boot mailing list