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)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Thu, 24 Aug 2023 17:24:15 +0000 (13:24 -0400)
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>
fs/nfs/pnfs_dev.c

index ddbbf4f..178001c 100644 (file)
@@ -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: