]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
NFSv4/pnfs: minor fix for cleanup path in nfs4_get_device_info
authorFedor Pchelkin <pchelkin@ispras.ru>
Thu, 20 Jul 2023 15:37:51 +0000 (18:37 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Sep 2023 08:47:01 +0000 (10:47 +0200)
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 <pchelkin@ispras.ru>
Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/nfs/pnfs_dev.c

index 2961fcd7a2df9292bf4f611287c2e48bdfe31ad2..da3852ff1fb39d8c5cf874a4a0f7183fab301c18 100644 (file)
@@ -153,7 +153,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: