Skip to content

Commit

Permalink
Merge pull request #366 from nbdd0121/rust
Browse files Browse the repository at this point in the history
binder: fix use-before-init of spinlock
  • Loading branch information
wedsonaf authored Jun 8, 2021
2 parents 7764b8c + 44d85c4 commit 5bb76a6
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 5bb76a6

Please sign in to comment.