diff options
author | Jesper Juhl <jj@chaosbits.net> | 2013-10-01 00:44:37 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-10-01 05:33:13 +0400 |
commit | b20204310ad18516146264830bc7b840b6052d57 (patch) | |
tree | 6e444dce6e585d709c09e7d84e59cad6cfab516d | |
parent | 78b4c76b5f1371c6161f4d5f9f16e061d69170ae (diff) | |
download | linux-b20204310ad18516146264830bc7b840b6052d57.tar.xz |
staging: lustre: Don't leak 'buffer' in cfs_get_environ()
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>
-rw-r--r-- | drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c index 6a26c6664f88..0bf8e5d87f1a 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c @@ -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; |