NFSD: fix problems with cleanup on errors in nfsd4_copy
authorDai Ngo <dai.ngo@oracle.com>
Tue, 31 Jan 2023 19:12:29 +0000 (11:12 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:33:24 +0000 (09:33 +0100)
commit598e2d5d911ded514146b02982c061ec61ee7829
tree37e095841b9678d3a5431c8eb343997b17930fab
parent75b8c681c563ef7e85da6862354efc18d2a08b1b
NFSD: fix problems with cleanup on errors in nfsd4_copy

[ Upstream commit 81e722978ad21072470b73d8f6a50ad62c7d5b7d ]

When nfsd4_copy fails to allocate memory for async_copy->cp_src, or
nfs4_init_copy_state fails, it calls cleanup_async_copy to do the
cleanup for the async_copy which causes page fault since async_copy
is not yet initialized.

This patche rearranges the order of initializing the fields in
async_copy and adds checks in cleanup_async_copy to skip un-initialized
fields.

Fixes: ce0887ac96d3 ("NFSD add nfs4 inter ssc to nfsd4_copy")
Fixes: 87689df69491 ("NFSD: Shrink size of struct nfsd4_copy")
Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfsd/nfs4proc.c
fs/nfsd/nfs4state.c