From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 437F4746F for ; Sun, 17 Sep 2023 20:36:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3EEBC433C7; Sun, 17 Sep 2023 20:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1694982970; bh=a5LeLMH5wMCmXwezla7CXF+3TcmGT+QE7/Aa/PfXbsw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cG3cfPnt2i8qi0d5xyCrrd1QE6YdQYOT5ZDEd9PEBuyPMp83bzuAS38JLDV1kzrRW UIDJQBvqhI2/XaCDXV0Lh80znXdoCCjLUw40nGPlz/FrtmngmOR+JsD+yiH/FYHsQ8 4z4113gqFz36xfGUInh9WtVAkDeCg780v6m/xFjU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Fedor Pchelkin , Benjamin Coddington , Anna Schumaker Subject: [PATCH 5.15 405/511] NFSv4/pnfs: minor fix for cleanup path in nfs4_get_device_info Date: Sun, 17 Sep 2023 21:13:52 +0200 Message-ID: <20230917191123.568193422@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917191113.831992765@linuxfoundation.org> References: <20230917191113.831992765@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fedor Pchelkin commit 96562c45af5c31b89a197af28f79bfa838fb8391 upstream. 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 Signed-off-by: Anna Schumaker Signed-off-by: Greg Kroah-Hartman --- fs/nfs/pnfs_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/nfs/pnfs_dev.c +++ b/fs/nfs/pnfs_dev.c @@ -154,7 +154,7 @@ nfs4_get_device_info(struct nfs_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: