Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4452752imw; Tue, 19 Jul 2022 06:56:41 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tVBjIQI8UCSqK3faEKitF0yPSvAca6T02JhUJHPHrbQJew0VBB7QpTGPjwmm+dFlIZ9Nvw X-Received: by 2002:a17:907:1c0a:b0:72b:378f:2fa1 with SMTP id nc10-20020a1709071c0a00b0072b378f2fa1mr29969605ejc.492.1658239000807; Tue, 19 Jul 2022 06:56:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658239000; cv=none; d=google.com; s=arc-20160816; b=zt/YerDghW/PuZ5WfE5W2OY4/DgnJFWptDOMsO8fjcFNZfg9wOJ1jDduxkrJogRgMG YcQifTAGJbXr4DJjD2Fuug1i5sGh3hk92SAyS4J+Gu350Fw9t7tXDCSBu1/ybyen8eT7 0lN3bJJIqcGflIRr520bxuXgIOjxG5cgl4YaqqrsLT6tibPEYneJfUwl712WDEY1E68i uT+opSjAhhSFjwx5xcMyfpyKlY8c+onj0oJVGzynq3mHIPnKQDGvSpMwzYhx3aD7cRBT 9uzm7sPHrqcWTNroRe0ovLxXigARrwWKo4t689jg1XUN8aA80zmQQ1nFeNFF2qwz7gMG j6kA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8EMF4CtpqmQbtiR15ck7oXRa2o15nOzy7wHBK9z09sE=; b=S8Rxl8lg7tuzFIlSlV4peKaHc9Vt0ufwQm+b/bFPGdbS8eFaDSv8GHAmw6jmb+Ud0y TJRVtWjJvh2h9HSTrkg4hB9dzrcxNSKDE0dluEP5CvjjI5jCaZYHjFmKRXZIT9w+VWyO EnxKjL4Pjo0A+1rlcRkAxABcezRg5bbLeXm8i2jPTAhx3zr0Hd11M/Ti3Nuy/gOT5kW3 0NnEUnW3TsGfAwE4lvaabSxh9vJMz1QZTg6GnT4bmP+K/eppDt6eNnCH0AcpK1Tk/t6x 2uXsd+2eCCKFInXimSGyEd0DMI0zk5cDB8cvalkqx7Vh+gvhQGyZ8mFn+2mfKwxIN4iy a1Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kaGuXo3Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm12-20020a170907948c00b0072f3533752bsi8634764ejc.161.2022.07.19.06.56.15; Tue, 19 Jul 2022 06:56:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=kaGuXo3Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240895AbiGSMiO (ORCPT + 99 others); Tue, 19 Jul 2022 08:38:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240886AbiGSMhy (ORCPT ); Tue, 19 Jul 2022 08:37:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 754D67BE01; Tue, 19 Jul 2022 05:14:32 -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 E651EB81B32; Tue, 19 Jul 2022 12:14:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 466AAC341C6; Tue, 19 Jul 2022 12:14:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232862; bh=Mg3fED1AAvaDbJxZHyGG4Bsb6lTRQRN91wZoWjfGKTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kaGuXo3YT0D4T2Wlh3az3I3xMV0uSpB0WirYwnRunGDfwcQm2Jh4FaVSsR9D7vDke g6lOFb7hJE1YjSr2SJatCwZ9E1ipeLoeOMhgSuTn7sxn9vVO/BxG6nlD0ZrWvi0q1n fWU2VmhoB5QxXBhAOkxRy3m60ZUidXkqiWcduchc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "J. Bruce Fields" , Jeff Layton , Chuck Lever , Sasha Levin Subject: [PATCH 5.15 072/167] lockd: fix nlm_close_files Date: Tue, 19 Jul 2022 13:53:24 +0200 Message-Id: <20220719114703.467947727@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114656.750574879@linuxfoundation.org> References: <20220719114656.750574879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 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 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-kernel@vger.kernel.org From: Jeff Layton [ Upstream commit 1197eb5906a5464dbaea24cac296dfc38499cc00 ] 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 Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- 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.35.1