Skip to content

Commit

Permalink
binder: fix use-before-init of spinlock
Browse files Browse the repository at this point in the history
This causes `BUG: spinlock bad magic`.

Signed-off-by: Gary Guo <[email protected]>
  • Loading branch information
nbdd0121 committed Jun 8, 2021
1 parent 7764b8c commit 44d85c4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/android/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,16 @@ impl Thread {
work_condvar: unsafe { CondVar::new() },
links: Links::new(),
})?;
{
let mut inner = arc.inner.lock();
inner.set_reply_work(reply_work);
inner.set_return_work(return_work);
}
let thread = Arc::get_mut(&mut arc).unwrap();
// SAFETY: `inner` is pinned behind the `Arc` reference.
let inner = unsafe { Pin::new_unchecked(&thread.inner) };
kernel::spinlock_init!(inner, "Thread::inner");
kernel::condvar_init!(thread.pinned_condvar(), "Thread::work_condvar");
{
let mut inner = arc.inner.lock();
inner.set_reply_work(reply_work);
inner.set_return_work(return_work);
}
Ok(arc)
}

Expand Down

0 comments on commit 44d85c4

Please sign in to comment.