diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 619194857c..0f5f2fc46b 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -678,6 +678,7 @@ thermal_zone_device_register(FAR const char *name, FAR struct thermal_governor_s *gov; FAR struct thermal_zone_device_s *pos; FAR struct thermal_zone_device_s *zdev; + int i; if (!ops || !ops->get_temp) { @@ -685,6 +686,15 @@ thermal_zone_device_register(FAR const char *name, return NULL; } + for (i = 0; i < params->num_trips; i++) + { + if (params->trips[i].type >= THERMAL_TRIP_TYPE_MAX) + { + therr("Invalid trip type (%d)!\n", params->trips[i].type); + return NULL; + } + } + nxmutex_lock(&g_thermal_lock); list_for_every_entry(&g_zone_dev_list, pos, diff --git a/include/nuttx/thermal.h b/include/nuttx/thermal.h index 53a7c668a2..22bcce71a4 100644 --- a/include/nuttx/thermal.h +++ b/include/nuttx/thermal.h @@ -69,10 +69,10 @@ enum thermal_trend_e enum thermal_trip_type_e { - THERMAL_COLD, THERMAL_NORMAL, THERMAL_HOT, THERMAL_CRITICAL, + THERMAL_TRIP_TYPE_MAX, }; struct thermal_governor_s