]> Git Repo - J-linux.git/commitdiff
NFSD: Initialize struct nfsd4_copy earlier
authorChuck Lever <[email protected]>
Sat, 26 Oct 2024 16:02:38 +0000 (12:02 -0400)
committerChuck Lever <[email protected]>
Tue, 29 Oct 2024 19:31:18 +0000 (15:31 -0400)
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 <[email protected]>
Fixes: aadc3bbea163 ("NFSD: Limit the number of concurrent async COPY operations")
Reviewed-by: Jeff Layton <[email protected]>
Tested-by: Olga Kornievskaia <[email protected]>
Signed-off-by: Chuck Lever <[email protected]>
fs/nfsd/nfs4proc.c

index b5a6bf4f459fb2309a0ccc9f585c5d6318ceedf1..5fd1ce3fc8fb7e638715ab6d9af21b5a73459977 100644 (file)
@@ -1841,14 +1841,14 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
                if (!async_copy)
                        goto out_err;
                async_copy->cp_nn = nn;
+               INIT_LIST_HEAD(&async_copy->copies);
+               refcount_set(&async_copy->refcount, 1);
                /* Arbitrary cap on number of pending async copy operations */
                if (atomic_inc_return(&nn->pending_async_copies) >
                                (int)rqstp->rq_pool->sp_nrthreads) {
                        atomic_dec(&nn->pending_async_copies);
                        goto out_err;
                }
-               INIT_LIST_HEAD(&async_copy->copies);
-               refcount_set(&async_copy->refcount, 1);
                async_copy->cp_src = kmalloc(sizeof(*async_copy->cp_src), GFP_KERNEL);
                if (!async_copy->cp_src)
                        goto out_err;
This page took 0.05077 seconds and 4 git commands to generate.