From: Sudeep Holla Date: Thu, 15 Mar 2018 16:54:18 +0000 (+0000) Subject: hwmon: (scmi) return -EINVAL when sensor information is unavailable X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=c09880cef78d0ddf149cdfeb733027a806465ba2;p=linux.git hwmon: (scmi) return -EINVAL when sensor information is unavailable 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 Acked-by: Guenter Roeck Cc: linux-hwmon@vger.kernel.org Signed-off-by: Sudeep Holla --- diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c index 32e750373cede..363bf56eb0f29 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: