summaryrefslogtreecommitdiff
path: root/kernel/power
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2024-01-29 17:24:30 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2024-02-05 14:28:54 +0100
commita6d38e991dc4f1b4a86137177435660df53951c5 (patch)
treeae43827d9220c299951c4a5dfd2c697609ded4de /kernel/power
parent4add3e72f0fca0c66a8c9de8f58997eb9a3e3320 (diff)
PM: sleep: stats: Use locking in dpm_save_failed_dev()
Because dpm_save_failed_dev() may be called simultaneously by multiple failing device PM functions, the state of the suspend_stats fields updated by it may become inconsistent. Prevent that from happening by using a lock in dpm_save_failed_dev(). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'kernel/power')
-rw-r--r--kernel/power/main.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 8c4bf5a54805..a9e0693aaf69 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -325,13 +325,18 @@ struct suspend_stats {
};
static struct suspend_stats suspend_stats;
+static DEFINE_MUTEX(suspend_stats_lock);
void dpm_save_failed_dev(const char *name)
{
+ mutex_lock(&suspend_stats_lock);
+
strscpy(suspend_stats.failed_devs[suspend_stats.last_failed_dev],
name, sizeof(suspend_stats.failed_devs[0]));
suspend_stats.last_failed_dev++;
suspend_stats.last_failed_dev %= REC_FAILED_NUM;
+
+ mutex_unlock(&suspend_stats_lock);
}
void dpm_save_failed_step(enum suspend_stat_step step)