Whamcloud - gitweb
LU-8249 lnet: potential deadlock in lnet 76/20676/6
authorQuentin Bouget <quentin.bouget.ocre@cea.fr>
Thu, 16 Jun 2016 21:46:42 +0000 (17:46 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 29 Aug 2016 03:52:16 +0000 (03:52 +0000)
Fixes potential deadlock in LNetMDAttach (vfree must not be called in
interrupt context in linux kernel versions prior to 3.10).

Signed-off-by: Quentin Bouget <quentin.bouget.ocre@cea.fr>
Change-Id: I1b421b470bab97d58f441040c39b9f1caf11b1fe
Reviewed-on: http://review.whamcloud.com/20676
Reviewed-by: Doug Oucharek <doug.s.oucharek@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Henri Doreau <henri.doreau@cea.fr>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lnet/lnet/lib-md.c

index c139934..4c6fb17 100644 (file)
@@ -285,11 +285,12 @@ LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd,
                 return -ENOMEM;
 
        rc = lnet_md_build(md, &umd, unlink);
+       if (rc != 0)
+               goto out_free;
+
        cpt = lnet_cpt_of_cookie(meh.cookie);
 
        lnet_res_lock(cpt);
-       if (rc != 0)
-               goto failed;
 
        me = lnet_handle2me(&meh);
        if (me == NULL)
@@ -300,7 +301,7 @@ LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd,
                rc = lnet_md_link(md, umd.eq_handle, cpt);
 
        if (rc != 0)
-               goto failed;
+               goto out_unlock;
 
        /* attach this MD to portal of ME and check if it matches any
         * blocked msgs on this portal */
@@ -315,10 +316,10 @@ LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd,
 
        return 0;
 
- failed:
-       lnet_md_free(md);
-
+out_unlock:
        lnet_res_unlock(cpt);
+out_free:
+       lnet_md_free(md);
        return rc;
 }
 EXPORT_SYMBOL(LNetMDAttach);
@@ -361,24 +362,25 @@ LNetMDBind(lnet_md_t umd, lnet_unlink_t unlink, lnet_handle_md_t *handle)
                 return -ENOMEM;
 
        rc = lnet_md_build(md, &umd, unlink);
+       if (rc != 0)
+               goto out_free;
 
        cpt = lnet_res_lock_current();
-       if (rc != 0)
-               goto failed;
 
        rc = lnet_md_link(md, umd.eq_handle, cpt);
        if (rc != 0)
-               goto failed;
+               goto out_unlock;
 
        lnet_md2handle(handle, md);
 
        lnet_res_unlock(cpt);
        return 0;
 
- failed:
-       lnet_md_free(md);
-
+ out_unlock:
        lnet_res_unlock(cpt);
+
+ out_free:
+       lnet_md_free(md);
        return rc;
 }
 EXPORT_SYMBOL(LNetMDBind);