linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] hwmon: (scmi) return -EINVAL when sensor information is unavailable
@ 2018-03-15 18:08 Sudeep Holla
  2018-03-15 21:27 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Sudeep Holla @ 2018-03-15 18:08 UTC (permalink / raw)
  To: linux-kernel; +Cc: Sudeep Holla, Dan Carpenter, Guenter Roeck, linux-hwmon

Passing NULL pointer to PTR_ERR will result in return value of 0
indicating success which is clearly not what it is intended here.

This patch returns -EINVAL instead when the sensor information is not
available.

Fixes: b23688aefb8b ("hwmon: add support for sensors exported via ARM SCMI")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/hwmon/scmi-hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Hi Guenter,

I will try to push this via ARM-SoC if possible before v4.17 merge window.
So please provide Ack if you are fine.

Regards,
Sudeep

diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c
index 32e750373ced..363bf56eb0f2 100644
--- a/drivers/hwmon/scmi-hwmon.c
+++ b/drivers/hwmon/scmi-hwmon.c
@@ -138,7 +138,7 @@ static int scmi_hwmon_probe(struct scmi_device *sdev)
 	for (i = 0; i < nr_sensors; i++) {
 		sensor = handle->sensor_ops->info_get(handle, i);
 		if (!sensor)
-			return PTR_ERR(sensor);
+			return -EINVAL;
 
 		switch (sensor->type) {
 		case TEMPERATURE_C:
-- 
2.7.4

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

* Re: [PATCH -next] hwmon: (scmi) return -EINVAL when sensor information is unavailable
  2018-03-15 18:08 [PATCH -next] hwmon: (scmi) return -EINVAL when sensor information is unavailable Sudeep Holla
@ 2018-03-15 21:27 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2018-03-15 21:27 UTC (permalink / raw)
  To: Sudeep Holla, linux-kernel; +Cc: Dan Carpenter, linux-hwmon

On 03/15/2018 11:08 AM, Sudeep Holla wrote:
> Passing NULL pointer to PTR_ERR will result in return value of 0
> indicating success which is clearly not what it is intended here.
> 
> This patch returns -EINVAL instead when the sensor information is not
> available.
> 
> Fixes: b23688aefb8b ("hwmon: add support for sensors exported via ARM SCMI")
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: linux-hwmon@vger.kernel.org
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

Acked-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/hwmon/scmi-hwmon.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Hi Guenter,
> 
> I will try to push this via ARM-SoC if possible before v4.17 merge window.
> So please provide Ack if you are fine.
> 
> Regards,
> Sudeep
> 
> diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c
> index 32e750373ced..363bf56eb0f2 100644
> --- a/drivers/hwmon/scmi-hwmon.c
> +++ b/drivers/hwmon/scmi-hwmon.c
> @@ -138,7 +138,7 @@ static int scmi_hwmon_probe(struct scmi_device *sdev)
>   	for (i = 0; i < nr_sensors; i++) {
>   		sensor = handle->sensor_ops->info_get(handle, i);
>   		if (!sensor)
> -			return PTR_ERR(sensor);
> +			return -EINVAL;
>   
>   		switch (sensor->type) {
>   		case TEMPERATURE_C:
> 

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

end of thread, other threads:[~2018-03-15 21:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-15 18:08 [PATCH -next] hwmon: (scmi) return -EINVAL when sensor information is unavailable Sudeep Holla
2018-03-15 21:27 ` 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).