Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3598537imw; Mon, 11 Jul 2022 11:43:52 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tyLCQY3zJarSezAgdDbqUjLVcEsh6AJxJF/dSQJpQk90XeL9wFpwQsWulzbR9rq3cHgurO X-Received: by 2002:a17:907:2895:b0:72a:f3bd:6e5f with SMTP id em21-20020a170907289500b0072af3bd6e5fmr19855086ejc.767.1657565032517; Mon, 11 Jul 2022 11:43:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657565032; cv=none; d=google.com; s=arc-20160816; b=IqXszYGZATfLme5Xx84hzMPm1HWQTyeVjjHCskfo/z1gkzz75OFUGGMA2TSojqEQlx DGb1x5wyuKRmCwuFTO/rGd6iAzzvnW5BOUF/DT6ZcThyBNylXfg+46qGjFfv2R1xovHK m1qs6BJh9iOEyxcqvB+2jYD9jYcXwZ8eQJGVIVfVUZEAw+YGwNHz5T4gV3FSAQVRGjlT dWjfsfrJd/yvVaUj+5dg7ZAFQiYr3TDX/14JMLX2VTJ9APDUbT7faJe7YPGlpKId/rd6 3OV9CJvdSy1szZ3ZKYMp7DzKsxZTc+VuB4Acb2S3Q/AiKj06pR6qugfEsuuDacmLeHwA kb/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YdI785Ym99JQA0lMZoqMydIZxkz+SETTuCRWwEA97K4=; b=raqU0zH/PqZWnrDXNUgq4r/de2qqoa4QjvLte85mregCbrevMIy8WSpCYenV1k0vsQ XB6C7Qa3v9u40xaOGT/kQUY12XnswMjqagvPY5HWiU+BhV0X6Uzmps87Ugu53cuO9gok UME4J7Iv1yNMlasoVteHKgqVi89VfUS7qnpCHWpKcv4mf/yYyuc7PJFyQJxkdwvDCkiW p9OLdnS2hqeaCTdRkIHHrbanD2o8Rj3UEiYU/Nz1c/aA12R07/pEF1rGr/Heh+McIzI1 70NLRE74aHCBONziYi/t/9cHazYEjrWw5Mr0tTi9NaGws+c7sw/kfo4zWNrsc3+lVYUI Pa/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KU311Q1Z; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l22-20020a1709060e1600b006ff78d48b00si10215070eji.534.2022.07.11.11.43.25; Mon, 11 Jul 2022 11:43:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KU311Q1Z; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229754AbiGKSay (ORCPT + 99 others); Mon, 11 Jul 2022 14:30:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbiGKSay (ORCPT ); Mon, 11 Jul 2022 14:30:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 226027CB61 for ; Mon, 11 Jul 2022 11:30:21 -0700 (PDT) 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 98234B8112C for ; Mon, 11 Jul 2022 18:30:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFA4DC385A5; Mon, 11 Jul 2022 18:30:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657564218; bh=eV5RfACFcPUgyHQNa3DtRiysZ+StIc5V6bvBdC+yDUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KU311Q1ZDQfxT4U3YCxEZHr19xmXdKUf8NOep6fXTzbMNXqZfy6axwuWWwxSJw7Ms kQ+zAF3NUAn8o7QGOAOLQP+Sp0JjHJ0SAz2ItCn3jH9BR9JigbnvTTCQn+nOxyfFnC rJMjjCKM9IVK5pjQ2TjfBuUo/LEReBAwJZyv1a3GrbrZYVSATalzjfgC6i7Vbqe024 +KxkTSfG9f/JZnwI8O2zrf645UTlLtkMEcgCV+GW047enecw8he30QuEfK08WcvOup xAFw/zu7+G4Y2teYztUBXYaG/ZGU68/vFViarFvcbg1MiPQz/K8E2FZ4OQ6iUA2cX/ ngZPPANk9rcIA== From: Jeff Layton To: chuck.lever@oracle.com Cc: linux-nfs@vger.kernel.org, trond.myklebust@hammerspace.com, anna@kernel.org, "J . Bruce Fields" Subject: [PATCH 2/2] lockd: fix nlm_close_files Date: Mon, 11 Jul 2022 14:30:14 -0400 Message-Id: <20220711183014.15161-3-jlayton@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220711183014.15161-1-jlayton@kernel.org> References: <20220711183014.15161-1-jlayton@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org This loop condition tries a bit too hard to be clever. Just test for the two indices we care about explicitly. Cc: J. Bruce Fields Fixes: 7f024fcd5c97 ("Keep read and write fds with each nlm_file") Signed-off-by: Jeff Layton --- fs/lockd/svcsubs.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index b2f277727469..e1c4617de771 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -283,11 +283,10 @@ nlm_file_inuse(struct nlm_file *file) static void nlm_close_files(struct nlm_file *file) { - struct file *f; - - for (f = file->f_file[0]; f <= file->f_file[1]; f++) - if (f) - nlmsvc_ops->fclose(f); + if (file->f_file[O_RDONLY]) + nlmsvc_ops->fclose(file->f_file[O_RDONLY]); + if (file->f_file[O_WRONLY]) + nlmsvc_ops->fclose(file->f_file[O_WRONLY]); } /* -- 2.36.1