From patchwork Thu Jul 20 15:37:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fedor Pchelkin X-Patchwork-Id: 13320725 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 13DF0EB64DA for ; Thu, 20 Jul 2023 15:54:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233023AbjGTPyF (ORCPT ); Thu, 20 Jul 2023 11:54:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233016AbjGTPyC (ORCPT ); Thu, 20 Jul 2023 11:54:02 -0400 X-Greylist: delayed 600 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 20 Jul 2023 08:53:44 PDT Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81D631BF7; Thu, 20 Jul 2023 08:53:44 -0700 (PDT) Received: from localhost.localdomain (unknown [46.242.14.200]) by mail.ispras.ru (Postfix) with ESMTPSA id 083D540ADFF5; Thu, 20 Jul 2023 15:38:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 083D540ADFF5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1689867484; bh=RUxFS+LWIM3YhaUDAXCqrt+YL7/wWoooH1hTSPAwD8s=; h=From:To:Cc:Subject:Date:From; b=R/n6PuMS+c6RJI5IoOn0BJdygZ24lgzEt8xEeEar9gHB4DOAmdWTfpcX8PtoZyRzB I3J6N/BEHYk3Mjj6cVh12S+/3Hyt5n4ncqlYyU0lGQzX2dnv55XEOAsx5jow7EsPim lkaIjYJH7yb3XcVwigdneijLqy7Snx9Epoti/mjc= From: Fedor Pchelkin To: Trond Myklebust Cc: Fedor Pchelkin , Anna Schumaker , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org, stable@vger.kernel.org Subject: [PATCH] NFSv4/pnfs: minor fix for cleanup path in nfs4_get_device_info Date: Thu, 20 Jul 2023 18:37:51 +0300 Message-ID: <20230720153753.20497-1-pchelkin@ispras.ru> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org It is an almost improbable error case but when page allocating loop in nfs4_get_device_info() fails then we should only free the already allocated pages, as __free_page() can't deal with NULL arguments. Found by Linux Verification Center (linuxtesting.org). Cc: stable@vger.kernel.org Signed-off-by: Fedor Pchelkin Reviewed-by: Benjamin Coddington --- fs/nfs/pnfs_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/pnfs_dev.c b/fs/nfs/pnfs_dev.c index ddbbf4fcda86..178001c90156 100644 --- a/fs/nfs/pnfs_dev.c +++ b/fs/nfs/pnfs_dev.c @@ -154,7 +154,7 @@ nfs4_get_device_info(struct nfs_server *server, set_bit(NFS_DEVICEID_NOCACHE, &d->flags); out_free_pages: - for (i = 0; i < max_pages; i++) + while (--i >= 0) __free_page(pages[i]); kfree(pages); out_free_pdev: