Skip to content

Commit 63fab04

Browse files
committed
NFSD: Initialize struct nfsd4_copy earlier
Ensure the refcount and async_copies fields are initialized early. cleanup_async_copy() will reference these fields if an error occurs in nfsd4_copy(). If they are not correctly initialized, at the very least, a refcount underflow occurs. Reported-by: Olga Kornievskaia <okorniev@redhat.com> Fixes: aadc3bb ("NFSD: Limit the number of concurrent async COPY operations") Reviewed-by: Jeff Layton <jlayton@kernel.org> Tested-by: Olga Kornievskaia <okorniev@redhat.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent d5ff2fb commit 63fab04

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/nfsd/nfs4proc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,14 +1841,14 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
18411841
if (!async_copy)
18421842
goto out_err;
18431843
async_copy->cp_nn = nn;
1844+
INIT_LIST_HEAD(&async_copy->copies);
1845+
refcount_set(&async_copy->refcount, 1);
18441846
/* Arbitrary cap on number of pending async copy operations */
18451847
if (atomic_inc_return(&nn->pending_async_copies) >
18461848
(int)rqstp->rq_pool->sp_nrthreads) {
18471849
atomic_dec(&nn->pending_async_copies);
18481850
goto out_err;
18491851
}
1850-
INIT_LIST_HEAD(&async_copy->copies);
1851-
refcount_set(&async_copy->refcount, 1);
18521852
async_copy->cp_src = kmalloc(sizeof(*async_copy->cp_src), GFP_KERNEL);
18531853
if (!async_copy->cp_src)
18541854
goto out_err;

0 commit comments

Comments
 (0)