[PATCH 19/31] hwmon: (pmbus/max15301) use 4-argument i2c_smbus_read_block_data()
From: Dmitry Torokhov
Date: Sat Oct 24 2026 - 23:11:53 EST
Pass the buffer capacity reserving space for a trailing NUL byte to
i2c_smbus_read_block_data(), and ensure the device ID buffer is
NUL-terminated before comparison.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/hwmon/pmbus/max15301.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/pmbus/max15301.c b/drivers/hwmon/pmbus/max15301.c
index 4c36f1ea27ee..4db35453e432 100644
--- a/drivers/hwmon/pmbus/max15301.c
+++ b/drivers/hwmon/pmbus/max15301.c
@@ -66,11 +66,13 @@ static int max15301_probe(struct i2c_client *client)
| I2C_FUNC_SMBUS_BLOCK_DATA))
return -ENODEV;
- status = i2c_smbus_read_block_data(client, PMBUS_IC_DEVICE_ID, device_id);
+ status = i2c_smbus_read_block_data(client, PMBUS_IC_DEVICE_ID,
+ sizeof(device_id) - 1, device_id);
if (status < 0) {
dev_err(&client->dev, "Failed to read Device Id\n");
return status;
}
+ device_id[status] = '\0';
for (mid = max15301_id; mid->name[0]; mid++) {
if (!strncasecmp(mid->name, device_id, strlen(mid->name)))
break;
--
2.56.0.257.gf7497c7d27-goog