Skip to content

Commit

Permalink
ANDROID: binder: don't enqueue death notifications to thread todo.
Browse files Browse the repository at this point in the history
This allows userspace to request death notifications without
having to worry about getting an immediate callback on the same
thread; one scenario where this would be problematic is if the
death recipient handler grabs a lock that was already taken
earlier (eg as part of a nested transaction).

Signed-off-by: Martijn Coenen <maco@android.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Martijn Coenen authored and Greg Kroah-Hartman committed Sep 1, 2017
1 parent 858b271 commit bb74562
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions drivers/android/binder.c
Original file line number Diff line number Diff line change
Expand Up @@ -3499,22 +3499,12 @@ static int binder_thread_write(struct binder_proc *proc,
ref->death = death;
if (ref->node->proc == NULL) {
ref->death->work.type = BINDER_WORK_DEAD_BINDER;
if (thread->looper &
(BINDER_LOOPER_STATE_REGISTERED |
BINDER_LOOPER_STATE_ENTERED))
binder_enqueue_work(
proc,
&ref->death->work,
&thread->todo);
else {
binder_inner_proc_lock(proc);
binder_enqueue_work_ilocked(
&ref->death->work,
&proc->todo);
binder_wakeup_proc_ilocked(
proc);
binder_inner_proc_unlock(proc);
}

binder_inner_proc_lock(proc);
binder_enqueue_work_ilocked(
&ref->death->work, &proc->todo);
binder_wakeup_proc_ilocked(proc);
binder_inner_proc_unlock(proc);
}
} else {
if (ref->death == NULL) {
Expand Down

0 comments on commit bb74562

Please sign in to comment.