nfsd: zero out pointers after putting nfsd_files on COPY setup error
authorJeff Layton <jlayton@kernel.org>
Tue, 17 Jan 2023 19:38:30 +0000 (14:38 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 20 Feb 2023 14:20:52 +0000 (09:20 -0500)
At first, I thought this might be a source of nfsd_file overputs, but
the current callers seem to avoid an extra put when nfsd4_verify_copy
returns an error.

Still, it's "bad form" to leave the pointers filled out when we don't
have a reference to them anymore, and that might lead to bugs later.
Zero them out as a defensive coding measure.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4proc.c

index 3b73e4d..95234c8 100644 (file)
@@ -1214,8 +1214,10 @@ out:
        return status;
 out_put_dst:
        nfsd_file_put(*dst);
+       *dst = NULL;
 out_put_src:
        nfsd_file_put(*src);
+       *src = NULL;
        goto out;
 }