NFSv4.2: fix error return on memory allocation failure
authorColin Ian King <colin.king@canonical.com>
Wed, 16 Dec 2020 12:25:13 +0000 (12:25 +0000)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Wed, 16 Dec 2020 12:54:42 +0000 (07:54 -0500)
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>
fs/nfs/nfs42proc.c

index b9836e2ce4a2fb9307e8006922d0a7e065eb9359..f3fd935620fcb33e34fe3e1c63402746886b595e 100644 (file)
@@ -1301,6 +1301,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;
                }
        }