Skip to content

Commit

Permalink
nfsd: Fix a memory leak in an error handling path
Browse files Browse the repository at this point in the history
[ Upstream commit fd1ef88 ]

If this memdup_user() call fails, the memory allocated in a previous call
a few lines above should be freed. Otherwise it leaks.

Fixes: 6ee95d1 ("nfsd: add support for upcall version 2")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
tititiou36 authored and gregkh committed Oct 21, 2022
1 parent 89bca73 commit cc3bca2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/nfsd/nfs4recover.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,8 +815,10 @@ __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg,
princhash.data = memdup_user(
&ci->cc_princhash.cp_data,
princhashlen);
if (IS_ERR_OR_NULL(princhash.data))
if (IS_ERR_OR_NULL(princhash.data)) {
kfree(name.data);
return -EFAULT;
}
princhash.len = princhashlen;
} else
princhash.len = 0;
Expand Down

0 comments on commit cc3bca2

Please sign in to comment.