diff options
author | Yi-wei Zhao <gbjc64@motorola.com> | 2015-02-13 17:33:04 -0800 |
---|---|---|
committer | Simon Shields <keepcalm444@gmail.com> | 2016-06-13 14:47:40 +1000 |
commit | 2ed1b46030d9062ac9dc12ffef3beb3ece44d1a0 (patch) | |
tree | da109fc8984692fc60816017ce6168ba81863f6a /drivers | |
parent | eeaf4e63e771b8084bd2fecd58ec4430383e2ef5 (diff) | |
download | kernel_samsung_smdk4412-2ed1b46030d9062ac9dc12ffef3beb3ece44d1a0.tar.gz kernel_samsung_smdk4412-2ed1b46030d9062ac9dc12ffef3beb3ece44d1a0.tar.bz2 kernel_samsung_smdk4412-2ed1b46030d9062ac9dc12ffef3beb3ece44d1a0.zip |
staging:android:lmk: read rb tree root with spinlock
there is racing condition: after reading rb tree root, it might be changed
by other tasks before adding new node. it can lead to rb tree corruption.
This patch is to avoid this race condition.
Change-Id: Id86bfd133488ad4ee12cd83c9bf1d1c12ef5598f
Signed-off-by: Yi-wei Zhao <gbjc64@motorola.com>
Reviewed-on: http://gerrit.mot.com/715645
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Sheng-Zhe Zhao <a18689@motorola.com>
SLTApproved: Christopher Fries <cfries@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/android/lowmemorykiller.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c index a0731afce3f..caa7d3d392c 100644 --- a/drivers/staging/android/lowmemorykiller.c +++ b/drivers/staging/android/lowmemorykiller.c @@ -422,14 +422,16 @@ DEFINE_SPINLOCK(lmk_lock); struct rb_root tasks_scoreadj = RB_ROOT; void add_2_adj_tree(struct task_struct *task) { - struct rb_node **link = &tasks_scoreadj.rb_node; + struct rb_node **link; struct rb_node *parent = NULL; struct task_struct *task_entry; s64 key = task->signal->oom_score_adj; + /* * Find the right place in the rbtree: */ spin_lock(&lmk_lock); + link = &tasks_scoreadj.rb_node; while (*link) { parent = *link; task_entry = rb_entry(parent, struct task_struct, adj_node); |