lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241022190845.23536-1-surajsonawane0215@gmail.com>
Date: Wed, 23 Oct 2024 00:38:45 +0530
From: Suraj Sonawane <surajsonawane0215@...il.com>
To: tharunkumar.pasumarthi@...rochip.com,
	kumaravel.thiagarajan@...rochip.com
Cc: UNGLinuxDriver@...rochip.com,
	andi.shyti@...nel.org,
	linux-i2c@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Suraj Sonawane <surajsonawane0215@...il.com>
Subject: [PATCH] i2c: busses: fix uninit-value in pci1xxxx_i2c_xfer

Fix an issue reported by the smatch static analysis tool:
drivers/i2c/busses/i2c-mchp-pci1xxxx.c:1030 pci1xxxx_i2c_xfer() error:
uninitialized symbol 'retval'.

The error occurs because retval may be used without being set if the
transfer loop does not execute (e.g., when num is 0). This could cause
the function to return an undefined value, leading to unpredictable
behavior.

Initialize retval to 0 before the transfer loop to ensure that the
function returns a valid value even if no transfers are processed. This
change also preserves proper error handling within the loop.

Signed-off-by: Suraj Sonawane <surajsonawane0215@...il.com>
---
 drivers/i2c/busses/i2c-mchp-pci1xxxx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-mchp-pci1xxxx.c b/drivers/i2c/busses/i2c-mchp-pci1xxxx.c
index 5ef136c3e..4dfa11650 100644
--- a/drivers/i2c/busses/i2c-mchp-pci1xxxx.c
+++ b/drivers/i2c/busses/i2c-mchp-pci1xxxx.c
@@ -994,7 +994,7 @@ static int pci1xxxx_i2c_xfer(struct i2c_adapter *adap,
 {
 	struct pci1xxxx_i2c *i2c = i2c_get_adapdata(adap);
 	u8 slaveaddr;
-	int retval;
+	int retval = 0;
 	u32 i;
 
 	i2c->i2c_xfer_in_progress = true;
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ