Commit b2020431 authored by Jesper Juhl's avatar Jesper Juhl Committed by Greg Kroah-Hartman

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: default avatarJesper Juhl <jj@chaosbits.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 78b4c76b
...@@ -227,8 +227,10 @@ int cfs_get_environ(const char *key, char *value, int *val_len) ...@@ -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 * which is already holding mmap_sem for writes. If some other
* thread gets the write lock in the meantime, this thread will * thread gets the write lock in the meantime, this thread will
* block, but at least it won't deadlock on itself. LU-1735 */ * 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; return -EDEADLK;
}
up_read(&mm->mmap_sem); up_read(&mm->mmap_sem);
addr = mm->env_start; addr = mm->env_start;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment