Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA45CC6FA8E for ; Mon, 27 Feb 2023 02:13:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230298AbjB0CNe (ORCPT ); Sun, 26 Feb 2023 21:13:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230526AbjB0CNF (ORCPT ); Sun, 26 Feb 2023 21:13:05 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 639F51CF73; Sun, 26 Feb 2023 18:11:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 81B9DB80C9C; Mon, 27 Feb 2023 02:09:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5DDAC4339C; Mon, 27 Feb 2023 02:09:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677463793; bh=+bxx3jEIZaB25ey2yCSE+5XWptEuxuO9JkP7EjHpLSg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l1HsF12ImcmRlzn1A/F+an8evdG/fjLl0i7H26txQJGMJZQv9JTW4pwtF6JZnLbRh 9TQUVxrykDgp4FFuBGbFwVzeqfSjrks2aPQ/yCR8G6+DpptyLnumF0yAZwUbbhZn8O 2aCWEt6y1CvIEIh+T3btfRiIDfr4zkd8cgzV/5VM3v014WOT8Pel6Wcd6d568yLBU8 Vi5INhZonI4+RfK2n7b2+bDjV4yUYVavjLNvyj/vv9x8HWVXzWsOvTYpd1GOYiBpVD 9khHOQYwurz/XAI3B+wmAH2ChLuRv+J8/GgebwT0FhVIfTTjxxF7NjmjmNbUm9l7z/ hc2ViFDfeQ5VA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Sasha Levin , linux-nfs@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 25/25] nfsd: zero out pointers after putting nfsd_files on COPY setup error Date: Sun, 26 Feb 2023 21:08:48 -0500 Message-Id: <20230227020855.1051605-25-sashal@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230227020855.1051605-1-sashal@kernel.org> References: <20230227020855.1051605-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.0