Skip to contentSkip to conversation

hwmon: (pmbus/ibm-cffps) Prevent writing on_off_config with bad data

PATCH Applied Eddie James 2 participants 2 messages Jan 7, 2020 – Jan 11, 2020 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: (pmbus/ibm-cffps) Prevent writing on_off_config with bad data

If the user write parameters resulted in no bytes being written to the temporary buffer, then ON_OFF_CONFIG will be written with uninitialized data. Prevent this by bailing out in this case.

---
 drivers/hwmon/pmbus/ibm-cffps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/pmbus/ibm-cffps.c +1 -1
index 1c91ee1f9926..3795fe55b84f 100644
@@ -250,7 +250,7 @@ static ssize_t ibm_cffps_debugfs_write(struct file *file,
 		pmbus_set_page(psu->client, 0);
 
 		rc = simple_write_to_buffer(&data, 1, ppos, buf, count);
-		if (rc < 0)
+		if (rc <= 0)
 			return rc;
 
 		rc = i2c_smbus_write_byte_data(psu->client,
Signature · 1 line
2.24.0
maintainer Applied
#1 lore raw
Quoted 5 lines · Eddie James

If the user write parameters resulted in no bytes being written to the temporary buffer, then ON_OFF_CONFIG will be written with uninitialized data. Prevent this by bailing out in this case.

Applied.

Thanks,
Guenter

Quoted 17 lines
---
 drivers/hwmon/pmbus/ibm-cffps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/pmbus/ibm-cffps.c +1 -1
index 1c91ee1f9926..3795fe55b84f 100644
@@ -250,7 +250,7 @@ static ssize_t ibm_cffps_debugfs_write(struct file *file,
 		pmbus_set_page(psu->client, 0);
 
 		rc = simple_write_to_buffer(&data, 1, ppos, buf, count);
-		if (rc < 0)
+		if (rc <= 0)
 			return rc;
 
 		rc = i2c_smbus_write_byte_data(psu->client,