Skip to content

Commit

Permalink
staging: lustre: Don't leak 'buffer' in cfs_get_environ()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
jjuhl authored and gregkh committed Oct 1, 2013
1 parent 78b4c76 commit b202043
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b202043

Please sign in to comment.