Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=24bce5080306bd5255cbda3d6b09a29d5515b470
Commit:     24bce5080306bd5255cbda3d6b09a29d5515b470
Parent:     d025d7858f7415f558e89d870ad1a205954b64cd
Author:     Roland Dreier <[EMAIL PROTECTED]>
AuthorDate: Thu Jun 21 11:05:58 2007 -0700
Committer:  Roland Dreier <[EMAIL PROTECTED]>
CommitDate: Thu Jun 21 11:05:58 2007 -0700

    IB/umem: Fix possible hang on process exit
    
    If ib_umem_release() is called after ib_uverbs_close() sets 
context->closing,
    then a process can get stuck in a D state, because the code boils down to
    
        if (down_write_trylock(&mm->mmap_sem))
                down_write(&mm->mmap_sem);
    
    which is obviously a stupid instant deadlock.  Fix the code so that we
    only try to take the lock once.
    
    This bug was introduced in commit f7c6a7b5 ("IB/uverbs: Export
    ib_umem_get()/ib_umem_release() to modules") which fortunately never
    made it into a release, and was reported by Pete Wyckoff <[EMAIL 
PROTECTED]>.
    
    Signed-off-by: Roland Dreier <[EMAIL PROTECTED]>
---
 drivers/infiniband/core/umem.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index b4aec51..d40652a 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -225,13 +225,15 @@ void ib_umem_release(struct ib_umem *umem)
         * up here and not be able to take the mmap_sem.  In that case
         * we defer the vm_locked accounting to the system workqueue.
         */
-       if (context->closing && !down_write_trylock(&mm->mmap_sem)) {
-               INIT_WORK(&umem->work, ib_umem_account);
-               umem->mm   = mm;
-               umem->diff = diff;
-
-               schedule_work(&umem->work);
-               return;
+       if (context->closing) {
+               if (!down_write_trylock(&mm->mmap_sem)) {
+                       INIT_WORK(&umem->work, ib_umem_account);
+                       umem->mm   = mm;
+                       umem->diff = diff;
+
+                       schedule_work(&umem->work);
+                       return;
+               }
        } else
                down_write(&mm->mmap_sem);
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to