diff options
author | Anji Jonnala <anjir@codeaurora.org> | 2013-11-22 21:36:18 +0530 |
---|---|---|
committer | David Keitel <dkeitel@codeaurora.org> | 2016-03-22 11:08:21 -0700 |
commit | 939a7bbf7f47fbfe6819a2f9ad6b74947938b1d4 (patch) | |
tree | 8b7bda943d9ea193cc7a94f1a313722305f1038d | |
parent | 9e0b2db23b67a3d98004a1d68f0dc3a950da93bd (diff) |
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: Anji Jonnala <anjir@codeaurora.org>
-rw-r--r-- | drivers/thermal/thermal_core.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 7b7bd1c6ac8d..78e6f0bd1c8e 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -213,16 +213,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; |