hwmon: (sht4x) Reject incomplete heater command transfers
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.
---
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
@@ -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
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 10 lines
heater_enable_store()treats a zero return fromi2c_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_LENbefore updating the heater state, assht4x_probe()already does for the reset command.Fixes 0eed6fc3d2b9 ("hwmon: (sht4x): add heater support")Signed-off-by Baek Kyu, Kim <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 10 lines · Kim
heater_enable_store()treats a zero return fromi2c_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_LENbefore updating the heater state, assht4x_probe()already does for the reset command.Fixes 0eed6fc3d2b9 ("hwmon: (sht4x): add heater support")Signed-off-by Baek Kyu, Kim <[email protected]>
Applied.
Thanks,
Guenter