thermal: intel: int340x: Improve int340x_thermal_set_trip_temp()

Instead of using snprintf() to populate the ACPI object name in
int340x_thermal_set_trip_temp(), use an appropriate initializer
and make the function fail if its trip argument is greater than 9,
because ACPI object names can only be 4 characters long and it does
not make sense to even try to evaluate objects with longer names (that
argument is guaranteed to be non-negative, because it comes from the
thermal code that will not pass negative trip numbers to zone
callbacks).

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Tested-by: Zhang Rui <rui.zhang@intel.com>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
This commit is contained in:
Rafael J. Wysocki 2023-01-30 19:47:43 +01:00
parent d0009d14e9
commit 1bcebcab88
1 changed files with 4 additions and 2 deletions

View File

@ -42,10 +42,12 @@ static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone,
int trip, int temp) int trip, int temp)
{ {
struct int34x_thermal_zone *d = zone->devdata; struct int34x_thermal_zone *d = zone->devdata;
char name[] = {'P', 'A', 'T', '0' + trip, '\0'};
acpi_status status; acpi_status status;
char name[10];
snprintf(name, sizeof(name), "PAT%d", trip); if (trip > 9)
return -EINVAL;
status = acpi_execute_simple_method(d->adev->handle, name, status = acpi_execute_simple_method(d->adev->handle, name,
millicelsius_to_deci_kelvin(temp)); millicelsius_to_deci_kelvin(temp));
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))