Re: [PATCH] hwmon: (sg2042-mcu) reject short uptime reads
Ali Ahmet Memis <[email protected]> Sun, 2 Aug 2026 15:11:02 +0000
| Newsgroups | org.kernel.vger.linux-hwmon,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Aug 02 2026, Guenter Roeck wrote: > Please refrain from sending fixes for non-issues. You are right. Please drop it. I checked what i2c_smbus_read_i2c_block_data() returns without checking which protocol it runs, and the two block protocols do not behave the same. In i2c_smbus_xfer_emulated(), I2C_SMBUS_BLOCK_DATA sets I2C_M_RECV_LEN and reads back with memcpy(data->block, msg[1].buf, msg[1].buf[0] + 1); so there the device supplies the count and a short reply is a real thing. I2C_SMBUS_I2C_BLOCK_DATA, which is what this call uses, sets no I2C_M_RECV_LEN, sends msg[1].len = data->block[0] and reads back with memcpy(data->block + 1, msg[1].buf, data->block[0]); which never touches data->block[0]. An I2C block read carries no length byte on the wire, so nothing can shorten it, and a transfer that is cut short fails with an errno rather than returning a smaller count. time_val is fully written whenever the call succeeds. I should have read that before sending, rather than reasoning from the return value alone. Sorry for the noise, and for the stable Cc on top of it. -- Ali