]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/lockd/host.c
lockd: fix race in nlm_release()
[linux-2.6-omap-h63xx.git] / fs / lockd / host.c
index c3f119426d832ea396ebffbcd2820e335477bd8b..960911c4a11c60d72ff957e72f4951ab328f2d34 100644 (file)
@@ -529,12 +529,10 @@ nsm_release(struct nsm_handle *nsm)
 {
        if (!nsm)
                return;
+       mutex_lock(&nsm_mutex);
        if (atomic_dec_and_test(&nsm->sm_count)) {
-               mutex_lock(&nsm_mutex);
-               if (atomic_read(&nsm->sm_count) == 0) {
-                       list_del(&nsm->sm_link);
-                       kfree(nsm);
-               }
-               mutex_unlock(&nsm_mutex);
+               list_del(&nsm->sm_link);
+               kfree(nsm);
        }
+       mutex_unlock(&nsm_mutex);
 }