Whamcloud - gitweb
LU-5179 libcfs: do not leak mm_struct
[fs/lustre-release.git] / libcfs / libcfs / linux / linux-curproc.c
index 1452f14..525cebc 100644 (file)
@@ -206,10 +206,9 @@ int cfs_get_environ(const char *key, char *value, int *val_len)
         * which is already holding mmap_sem for writes.  If some other
         * thread gets the write lock in the meantime, this thread will
         * block, but at least it won't deadlock on itself.  LU-1735 */
-       if (down_read_trylock(&mm->mmap_sem) == 0) {
-               kfree(buffer);
-               return -EDEADLK;
-       }
+       if (down_read_trylock(&mm->mmap_sem) == 0)
+               GOTO(out, rc = -EDEADLK);
+
        up_read(&mm->mmap_sem);
 
        addr = mm->env_start;