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: <20251012-my_driver_work-v1-1-9e5fe6de51f4@gmail.com>
Date: Sun, 12 Oct 2025 17:13:27 +0530
From: Ranganath V N <vnranganath.20@...il.com>
To: Jean Delvare <jdelvare@...e.com>, Guenter Roeck <linux@...ck-us.net>
Cc: linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org, 
 skhan@...uxfoundation.org, david.hunter.linux@...il.com, khalid@...nel.org, 
 linux-kernel-mentees@...ts.linuxfoundation.org, 
 Ranganath V N <vnranganath.20@...il.com>
Subject: [PATCH] hwmon: sht3x: initialize variable 'ret' in
 update_interval_write().

fix for the smatch errors:
drivers/hwmon/sht3x.c:606 update_interval_write() error: uninitialized symbol 'ret'.

The warning can occur when both the data->mode and mode which is
derived from get_mode_from_update_interval() are zero.
In this case, no i2c command is sent and ret remains undefined
before reaching the coman return path.

When both data->mode and mode are zero, the device remains in
single shot mode and no configuration change is required.
In such cases, it is correct to treat the operation as successful
without issuing any i2c transfer.

To address this, initialize 'ret' to 'SHT3X_CMD_LENGTH'. this makes
the no-operation path return success while keeping the existing error
to all other paths.

This change removes the smatch errors. Tested by compiling.

Signed-off-by: Ranganath V N <vnranganath.20@...il.com>
---
 drivers/hwmon/sht3x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c
index 557ad3e7752a..4b52d57eaad8 100644
--- a/drivers/hwmon/sht3x.c
+++ b/drivers/hwmon/sht3x.c
@@ -553,7 +553,7 @@ static int update_interval_read(struct device *dev)
 static int update_interval_write(struct device *dev, int val)
 {
 	u8 mode;
-	int ret;
+	int ret = SHT3X_CMD_LENGTH;
 	const char *command;
 	struct sht3x_data *data = dev_get_drvdata(dev);
 	struct i2c_client *client = data->client;

---
base-commit: e5f0a698b34ed76002dc5cff3804a61c80233a7a
change-id: 20251012-my_driver_work-77b22c239e99

Best regards,
-- 
Ranganath V N <vnranganath.20@...il.com>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ