Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cd033f03 authored by Anji Jonnala's avatar Anji Jonnala Committed by Gerrit - the friendly Code Review server
Browse files

thermal-core: Fix invalid sensor request not accounted correctly



Add NULL check for sensor name before using it in sensor_get_id and
return NULL explicitly when sensor id is not valid in get_sensor of
thermal core.

Change-Id: I4200a5691183aa2d40ef8ed64554f0beb8ce6d0d
Signed-off-by: default avatarAnji Jonnala <anjir@codeaurora.org>
parent 7bd86da6
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -137,16 +137,19 @@ static struct sensor_info *get_sensor(uint32_t sensor_id)

	list_for_each_entry_safe(pos, var, &sensor_info_list, sensor_list) {
		if (pos->sensor_id == sensor_id)
			break;
			return pos;
	}

	return pos;
	return NULL;
}

int sensor_get_id(char *name)
{
	struct sensor_info *pos, *var;

	if (!name)
		return -ENODEV;

	list_for_each_entry_safe(pos, var, &sensor_info_list, sensor_list) {
		if (!strcmp(pos->tz->type, name))
			return pos->sensor_id;