linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: (pmbus/ibm-cffps) Prevent writing on_off_config with bad data
@ 2020-01-07 15:40 Eddie James
  2020-01-11  3:45 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Eddie James @ 2020-01-07 15:40 UTC (permalink / raw)
  To: linux-hwmon; +Cc: linux-kernel, jdelvare, linux, dan.carpenter, 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.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
 drivers/hwmon/pmbus/ibm-cffps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c
index 1c91ee1f9926..3795fe55b84f 100644
--- a/drivers/hwmon/pmbus/ibm-cffps.c
+++ b/drivers/hwmon/pmbus/ibm-cffps.c
@@ -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,
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hwmon: (pmbus/ibm-cffps) Prevent writing on_off_config with bad data
  2020-01-07 15:40 [PATCH] hwmon: (pmbus/ibm-cffps) Prevent writing on_off_config with bad data Eddie James
@ 2020-01-11  3:45 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2020-01-11  3:45 UTC (permalink / raw)
  To: Eddie James; +Cc: linux-hwmon, linux-kernel, jdelvare, dan.carpenter

On Tue, Jan 07, 2020 at 09:40:40AM -0600, Eddie James wrote:
> 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.
> 
> Signed-off-by: Eddie James <eajames@linux.ibm.com>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/pmbus/ibm-cffps.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c
> index 1c91ee1f9926..3795fe55b84f 100644
> --- a/drivers/hwmon/pmbus/ibm-cffps.c
> +++ b/drivers/hwmon/pmbus/ibm-cffps.c
> @@ -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,

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-11  3:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-07 15:40 [PATCH] hwmon: (pmbus/ibm-cffps) Prevent writing on_off_config with bad data Eddie James
2020-01-11  3:45 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).