Skip to content

Commit 4e3733f

Browse files
pchelkin91Trond Myklebust
authored andcommitted
NFSv4.2: fix error handling in nfs42_proc_getxattr
There is a slight issue with error handling code inside nfs42_proc_getxattr(). If page allocating loop fails then we free the failing page array element which is NULL but __free_page() can't deal with NULL args. Found by Linux Verification Center (linuxtesting.org). Fixes: a1f2673 ("NFSv4.2: improve page handling for GETXATTR") Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru> Reviewed-by: Benjamin Coddington <bcodding@redhat.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent c3dd7de commit 4e3733f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

fs/nfs/nfs42proc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,6 @@ ssize_t nfs42_proc_getxattr(struct inode *inode, const char *name,
13771377
for (i = 0; i < np; i++) {
13781378
pages[i] = alloc_page(GFP_KERNEL);
13791379
if (!pages[i]) {
1380-
np = i + 1;
13811380
err = -ENOMEM;
13821381
goto out;
13831382
}
@@ -1401,8 +1400,8 @@ ssize_t nfs42_proc_getxattr(struct inode *inode, const char *name,
14011400
} while (exception.retry);
14021401

14031402
out:
1404-
while (--np >= 0)
1405-
__free_page(pages[np]);
1403+
while (--i >= 0)
1404+
__free_page(pages[i]);
14061405
kfree(pages);
14071406

14081407
return err;

0 commit comments

Comments
 (0)