Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 66ed4d93 authored by Mahesh Sivasubramanian's avatar Mahesh Sivasubramanian
Browse files

msm-core: Fix race with userspace updating power numbers



When the user space application updates the existing leakage values, the
existing structures are freed and updated. If the polling worker thread is
executed at the same time, the worker thread could end up accessing memory
locations that were freed earlier.

Fix by using critical sections around free/update of the data structures.

Change-Id: I611585842c420653c925f83959dac9710b50ee2b
Signed-off-by: default avatarMahesh Sivasubramanian <msivasub@codeaurora.org>
parent 42162e39
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -397,6 +397,7 @@ static int update_userspace_power(struct sched_params __user *argp)
	/* Copy the same power values for all the cpus in the cpumask
	 * argp->cpumask within the cluster (argp->cluster)
	 */
	spin_lock(&update_lock);
	cpumask = argp->cpumask;
	for (i = 0; i < MAX_CORES_PER_CLUSTER; i++, cpumask >>= 1) {
		if (!(cpumask & 0x01))
@@ -419,6 +420,7 @@ static int update_userspace_power(struct sched_params __user *argp)
			repopulate_stats(cpu);
		}
	}
	spin_unlock(&update_lock);

	activate_power_table = true;
	return 0;