power: qcom: msm-core: Add mutex lock for ioctl
There can be use after free with multiple ioctl calls. Add mutex lock when updating userspace power. Change-Id: Ieae08d05478a462b19cf7f91b64267177eaebe84 Signed-off-by: Maulik Shah <mkshah@codeaurora.org> Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
This commit is contained in:
parent
d07da7cf99
commit
e13054cd17
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2014-2017, 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
|
||||
|
@ -380,9 +380,10 @@ static int update_userspace_power(struct sched_params __user *argp)
|
|||
if (!sp)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
mutex_lock(&policy_update_mutex);
|
||||
sp->power = allocate_2d_array_uint32_t(node->sp->num_of_freqs);
|
||||
if (IS_ERR_OR_NULL(sp->power)) {
|
||||
mutex_unlock(&policy_update_mutex);
|
||||
ret = PTR_ERR(sp->power);
|
||||
kfree(sp);
|
||||
return ret;
|
||||
|
@ -425,11 +426,13 @@ static int update_userspace_power(struct sched_params __user *argp)
|
|||
}
|
||||
}
|
||||
spin_unlock(&update_lock);
|
||||
mutex_unlock(&policy_update_mutex);
|
||||
|
||||
activate_power_table = true;
|
||||
return 0;
|
||||
|
||||
failed:
|
||||
mutex_unlock(&policy_update_mutex);
|
||||
for (i = 0; i < TEMP_DATA_POINTS; i++)
|
||||
kfree(sp->power[i]);
|
||||
kfree(sp->power);
|
||||
|
|
Loading…
Reference in New Issue