owner not checked in mutex_unlock

Chetan Nanda chetannanda at gmail.com
Thu Mar 10 04:29:31 EST 2016


Hi,

As per book (Linux kernel development)

"Whoever locked a mutex must unlock it.That is, you cannot lock a mutex in one
context and then unlock it in another
"
but 'mutex_unlock' code is not checking the owner field at all.

Also, I tried with locking the mutex from normal process context and
unlocking from separate context (work context) and it is allowed
without any error from kernel.

Is it the mutex user responsibility to keep track of it? Ideally
mutex_unlock should check if owner is same as current?

Thanks,
Chetan Nanda



More information about the Kernelnewbies mailing list