From patchwork Mon Jul 11 18:30:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 12914140 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 4B799C43334 for ; Mon, 11 Jul 2022 18:30:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229754AbiGKSay (ORCPT ); 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 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]); } /*