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 B88E86FC9 for ; Sun, 17 Sep 2023 19:40:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 296D4C433C9; Sun, 17 Sep 2023 19:40:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1694979626; bh=u1Qd/tXq41RIRhrkEl//ZYbRz6jrrAOuZr4CLzP4wjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xDxLZC+ix2mCe+dXcX7FUoofoKAZs4uIrIkH62BmrO8Gy8j8MGJU5sS+LaZz5np6H 0M5ACJjmfhLWgi/COpzTmxLcxBBLIDRBB7NdkMgwvxYgQ/IJoRyBEMhY2eYiuTQgPd +1/25gIEySrTw6E+c3wvsolO52B16sUHnmqL1Y6g= 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.10 333/406] NFSv4/pnfs: minor fix for cleanup path in nfs4_get_device_info Date: Sun, 17 Sep 2023 21:13:07 +0200 Message-ID: <20230917191110.078860307@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230917191101.035638219@linuxfoundation.org> References: <20230917191101.035638219@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.10-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 @@ -152,7 +152,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: