Commit 6e215785 authored by Alexey Starikovskiy's avatar Alexey Starikovskiy Committed by Len Brown

ACPI: Thermal: Drop concurrent thermal checks

Fix for #3686, where get_temperature() may cause thermal notify, which
causes one more get_temperature().
Signed-off-by: default avatarAlexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 21bc42ab
...@@ -195,6 +195,7 @@ struct acpi_thermal { ...@@ -195,6 +195,7 @@ struct acpi_thermal {
struct acpi_thermal_trips trips; struct acpi_thermal_trips trips;
struct acpi_handle_list devices; struct acpi_handle_list devices;
struct timer_list timer; struct timer_list timer;
struct mutex lock;
}; };
static const struct file_operations acpi_thermal_state_fops = { static const struct file_operations acpi_thermal_state_fops = {
...@@ -721,11 +722,15 @@ static void acpi_thermal_check(void *data) ...@@ -721,11 +722,15 @@ static void acpi_thermal_check(void *data)
return; return;
} }
/* Check if someone else is already running */
if (!mutex_trylock(&tz->lock))
return;
state = tz->state; state = tz->state;
result = acpi_thermal_get_temperature(tz); result = acpi_thermal_get_temperature(tz);
if (result) if (result)
return; goto unlock;
memset(&tz->state, 0, sizeof(tz->state)); memset(&tz->state, 0, sizeof(tz->state));
...@@ -816,8 +821,8 @@ static void acpi_thermal_check(void *data) ...@@ -816,8 +821,8 @@ static void acpi_thermal_check(void *data)
add_timer(&(tz->timer)); add_timer(&(tz->timer));
} }
} }
unlock:
return; mutex_unlock(&tz->lock);
} }
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
...@@ -1254,7 +1259,7 @@ static int acpi_thermal_add(struct acpi_device *device) ...@@ -1254,7 +1259,7 @@ static int acpi_thermal_add(struct acpi_device *device)
strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME); strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS); strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS);
acpi_driver_data(device) = tz; acpi_driver_data(device) = tz;
mutex_init(&tz->lock);
result = acpi_thermal_get_info(tz); result = acpi_thermal_get_info(tz);
if (result) if (result)
goto end; goto end;
...@@ -1324,7 +1329,7 @@ static int acpi_thermal_remove(struct acpi_device *device, int type) ...@@ -1324,7 +1329,7 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
} }
acpi_thermal_remove_fs(device); acpi_thermal_remove_fs(device);
mutex_destroy(&tz->lock);
kfree(tz); kfree(tz);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment