[PATCH 23/31] hwmon: (pmbus/pim4328) use 4-argument i2c_smbus_read_block_data()
From: Dmitry Torokhov
Date: Sat Oct 24 2026 - 23:09:07 EST
Pass sizeof(device_id) - 1 to i2c_smbus_read_block_data() in
pim4328_probe() to leave room for the NUL terminator, and ensure the
buffer is NUL-terminated before string comparisons.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/hwmon/pmbus/pim4328.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/pmbus/pim4328.c b/drivers/hwmon/pmbus/pim4328.c
index 9056dc387e87..2216f8db7ccb 100644
--- a/drivers/hwmon/pmbus/pim4328.c
+++ b/drivers/hwmon/pmbus/pim4328.c
@@ -150,11 +150,13 @@ static int pim4328_probe(struct i2c_client *client)
if (!data)
return -ENOMEM;
- status = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, device_id);
+ status = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL,
+ sizeof(device_id) - 1, device_id);
if (status < 0) {
dev_err(&client->dev, "Failed to read Manufacturer Model\n");
return status;
}
+ device_id[status] = '\0';
for (mid = pim4328_id; mid->name[0]; mid++) {
if (!strncasecmp(mid->name, device_id, strlen(mid->name)))
break;
--
2.56.0.257.gf7497c7d27-goog