]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: lustre: Don't leak 'buffer' in cfs_get_environ()
authorJesper Juhl <jj@chaosbits.net>
Mon, 30 Sep 2013 20:44:37 +0000 (22:44 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 1 Oct 2013 01:33:13 +0000 (18:33 -0700)
If 'down_read_trylock' fails we'll curently leak the memory allocated to 'buffer'.
Fix the leak by simply kfree'ing 'buffer' before returning '-EDEADLK'.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c

index 6a26c6664f88aeba953c8f17fecd439d73575e53..0bf8e5d87f1ad483035a3f0f93813530da56edc6 100644 (file)
@@ -227,8 +227,10 @@ 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)
+       if (down_read_trylock(&mm->mmap_sem) == 0) {
+               kfree(buffer);
                return -EDEADLK;
+       }
        up_read(&mm->mmap_sem);
 
        addr = mm->env_start;