From: Colin Ian King colin.king@canonical.com
mainline inclusion from mainline-v5.11-rc1 commit 7be9b38afafbfcc58ede3be66bfc4ea415b3d5f1 bugzilla: https://gitee.com/openeuler/kernel/issues/I6D0MJ
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
--------------------------------
Currently when an alloc_page fails the error return is not set in variable err and a garbage initialized value is returned. Fix this by setting err to -ENOMEM before taking the error return path.
Addresses-Coverity: ("Uninitialized scalar variable") Fixes: a1f26739ccdc ("NFSv4.2: improve page handling for GETXATTR") Signed-off-by: Colin Ian King colin.king@canonical.com Signed-off-by: Trond Myklebust trond.myklebust@hammerspace.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- fs/nfs/nfs42proc.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 52018571e501..06240e7093fc 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -1316,6 +1316,7 @@ ssize_t nfs42_proc_getxattr(struct inode *inode, const char *name, pages[i] = alloc_page(GFP_KERNEL); if (!pages[i]) { np = i + 1; + err = -ENOMEM; goto out; } }