Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5bb76a6

Browse files
authoredJun 8, 2021
Merge pull request #366 from nbdd0121/rust
binder: fix use-before-init of spinlock
2 parents 7764b8c + 44d85c4 commit 5bb76a6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎drivers/android/thread.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -245,16 +245,16 @@ impl Thread {
245245
work_condvar: unsafe { CondVar::new() },
246246
links: Links::new(),
247247
})?;
248-
{
249-
let mut inner = arc.inner.lock();
250-
inner.set_reply_work(reply_work);
251-
inner.set_return_work(return_work);
252-
}
253248
let thread = Arc::get_mut(&mut arc).unwrap();
254249
// SAFETY: `inner` is pinned behind the `Arc` reference.
255250
let inner = unsafe { Pin::new_unchecked(&thread.inner) };
256251
kernel::spinlock_init!(inner, "Thread::inner");
257252
kernel::condvar_init!(thread.pinned_condvar(), "Thread::work_condvar");
253+
{
254+
let mut inner = arc.inner.lock();
255+
inner.set_reply_work(reply_work);
256+
inner.set_return_work(return_work);
257+
}
258258
Ok(arc)
259259
}
260260

0 commit comments

Comments
 (0)
Failed to load comments.