From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4FE8BA4F for ; Tue, 7 Mar 2023 19:05:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A001C433EF; Tue, 7 Mar 2023 19:05:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678215953; bh=n0y7KjUqXpNVaax/q01jUPu5NubnLn/R+0HI8QyUROw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DzgXyoPrAl7VtuI1+PXYJyIlDd5SOWVbLxP39wb6VSOosFd2sw2WozudquEDHl3W2 SiEsLbnCzpLZ+20W+qeu5C5BMnE83a1/gk1+cr0iUTjk3ZfdIIepPIs8yhK/bWXIyb qmzGTGSY4sjh1EkJEE9A4GBbR6xrskRtD7Xkt/7o= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jeff Layton , Chuck Lever , Sasha Levin Subject: [PATCH 5.15 426/567] nfsd: zero out pointers after putting nfsd_files on COPY setup error Date: Tue, 7 Mar 2023 18:02:42 +0100 Message-Id: <20230307165924.350041001@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307165905.838066027@linuxfoundation.org> References: <20230307165905.838066027@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Jeff Layton [ Upstream commit 1f0001d43d0c0ac2a19a34a914f6595ad97cbc1d ] 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 Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- fs/nfsd/nfs4proc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 0a900b9e39eac..57af9c30eb48d 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1088,8 +1088,10 @@ nfsd4_verify_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, return status; out_put_dst: nfsd_file_put(*dst); + *dst = NULL; out_put_src: nfsd_file_put(*src); + *src = NULL; goto out; } -- 2.39.2