Skip to content

Commit 515c397

Browse files
JianyuWang0623xiaoxiang781216
authored andcommitted
Thermal: Check trip type in thermal_zone_device_register().
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
1 parent 6442683 commit 515c397

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

drivers/thermal/thermal_core.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,13 +678,23 @@ thermal_zone_device_register(FAR const char *name,
678678
FAR struct thermal_governor_s *gov;
679679
FAR struct thermal_zone_device_s *pos;
680680
FAR struct thermal_zone_device_s *zdev;
681+
int i;
681682

682683
if (!ops || !ops->get_temp)
683684
{
684685
therr("Invalid zone operations!\n");
685686
return NULL;
686687
}
687688

689+
for (i = 0; i < params->num_trips; i++)
690+
{
691+
if (params->trips[i].type >= THERMAL_TRIP_TYPE_MAX)
692+
{
693+
therr("Invalid trip type (%d)!\n", params->trips[i].type);
694+
return NULL;
695+
}
696+
}
697+
688698
nxmutex_lock(&g_thermal_lock);
689699

690700
list_for_every_entry(&g_zone_dev_list, pos,

include/nuttx/thermal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ enum thermal_trend_e
6969

7070
enum thermal_trip_type_e
7171
{
72-
THERMAL_COLD,
7372
THERMAL_NORMAL,
7473
THERMAL_HOT,
7574
THERMAL_CRITICAL,
75+
THERMAL_TRIP_TYPE_MAX,
7676
};
7777

7878
struct thermal_governor_s

0 commit comments

Comments
 (0)