linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] NFSv4/pnfs: minor fix for cleanup path in nfs4_get_device_info
@ 2023-07-20 15:37 Fedor Pchelkin
  2023-07-20 16:53 ` Benjamin Coddington
  0 siblings, 1 reply; 2+ messages in thread
From: Fedor Pchelkin @ 2023-07-20 15:37 UTC (permalink / raw)
  To: Trond Myklebust
  Cc: Fedor Pchelkin, Anna Schumaker, linux-nfs, linux-kernel,
	Alexey Khoroshilov, lvc-project, stable

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>
---
 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:
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] NFSv4/pnfs: minor fix for cleanup path in nfs4_get_device_info
  2023-07-20 15:37 [PATCH] NFSv4/pnfs: minor fix for cleanup path in nfs4_get_device_info Fedor Pchelkin
@ 2023-07-20 16:53 ` Benjamin Coddington
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Coddington @ 2023-07-20 16:53 UTC (permalink / raw)
  To: Fedor Pchelkin
  Cc: Trond Myklebust, Anna Schumaker, linux-nfs, linux-kernel,
	Alexey Khoroshilov, lvc-project, stable

On 20 Jul 2023, at 11:37, Fedor Pchelkin wrote:

> 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>

This looks correct to me.

Reviewed-by: Benjamin Coddington <bcodding@redhat.com>

Ben


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-20 16:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-20 15:37 [PATCH] NFSv4/pnfs: minor fix for cleanup path in nfs4_get_device_info Fedor Pchelkin
2023-07-20 16:53 ` Benjamin Coddington

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).