[PATCH 27/31] hwmon: (pmbus/stpddc60) use 4-argument i2c_smbus_read_block_data()
From: Dmitry Torokhov
Date: Sat Oct 24 2026 - 23:10:50 EST
Pass sizeof(device_id) - 1 to i2c_smbus_read_block_data() in
stpddc60_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/stpddc60.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/pmbus/stpddc60.c b/drivers/hwmon/pmbus/stpddc60.c
index b5ce7f975eea..9118517eabe8 100644
--- a/drivers/hwmon/pmbus/stpddc60.c
+++ b/drivers/hwmon/pmbus/stpddc60.c
@@ -205,11 +205,13 @@ static int stpddc60_probe(struct i2c_client *client)
| I2C_FUNC_SMBUS_BLOCK_DATA))
return -ENODEV;
- 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 = stpddc60_id; mid->name[0]; mid++) {
if (!strncasecmp(mid->name, device_id, strlen(mid->name)))
break;
--
2.56.0.257.gf7497c7d27-goog