Skip to contentSkip to conversation

hwmon: (sht4x) Reject incomplete heater command transfers

PATCH Applied Baek Kyu, Kim 3 participants 3 messages Oct 17 – Oct 18 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: (sht4x) Reject incomplete heater command transfers

heater_enable_store() treats a zero return from i2c_master_send() as success. It updates the heater state and returns count, so another attempt to enable the heater fails with -EBUSY.

i2c-virtio can return zero when the first message fails. Require SHT4X_CMD_LEN before updating the heater state, as sht4x_probe() already does for the reset command.

Fixes 0eed6fc3d2b9 ("hwmon: (sht4x): add heater support")

---
Tested with an emulated I2C adapter under ARM64 QEMU. A zero return reproduces the false success and -EBUSY on retry; both are fixed by this change. No physical sensor was tested.

 drivers/hwmon/sht4x.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/hwmon/sht4x.c +2 -0
index a97dda9e92dc..c4b3db55de8b 100644
@@ -287,2 +287,4 @@ static ssize_t heater_enable_store(struct device *dev,
 		return ret;
+	if (ret != SHT4X_CMD_LEN)
+		return -EIO;
 

base-commit: 58161ead29e50d70a317ea26b472e0c7508e69da

Signature · 1 line
2.55.0
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines

heater_enable_store() treats a zero return from i2c_master_send() as success. It updates the heater state and returns count, so another attempt to enable the heater fails with -EBUSY.

i2c-virtio can return zero when the first message fails. Require SHT4X_CMD_LEN before updating the heater state, as sht4x_probe() already does for the reset command.

Fixes 0eed6fc3d2b9 ("hwmon: (sht4x): add heater support")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Applied
#2 lore raw
In reply to Baek Kyu, Kim
Quoted 10 lines · Kim

heater_enable_store() treats a zero return from i2c_master_send() as success. It updates the heater state and returns count, so another attempt to enable the heater fails with -EBUSY.

i2c-virtio can return zero when the first message fails. Require SHT4X_CMD_LEN before updating the heater state, as sht4x_probe() already does for the reset command.

Fixes 0eed6fc3d2b9 ("hwmon: (sht4x): add heater support")

Applied.

Thanks,
Guenter