浏览代码

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 <dan.carpenter@oracle.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Sudeep Holla 7 年之前
父节点
当前提交
c09880cef7
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      drivers/hwmon/scmi-hwmon.c

+ 1 - 1
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: