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: b23688aefb ("hwmon: add support for sensors exported via ARM SCMI")
Reported-by: Dan Carpenter <[email protected]>
Acked-by: Guenter Roeck <[email protected]>
Cc: [email protected]
Signed-off-by: Sudeep Holla <[email protected]>
This commit is contained in:
Sudeep Holla 2018-03-15 16:54:18 +00:00
commit c09880cef7

View file

@ -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: