Skip to contentSkip to conversation

NFSv4.2: fix error return on memory allocation failure

PATCH New Colin King 1 participant 1 message Dec 16, 2020

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 NFSv4.2: fix error return on memory allocation failure

From: Colin Ian King <[email protected]>

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")
---
 fs/nfs/nfs42proc.c | 1 +
 1 file changed, 1 insertion(+)
fs/nfs/nfs42proc.c +1 -0
index b9836e2ce4a2..f3fd935620fc 100644
@@ -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;
 		}
 	}
Signature · 1 line
2.29.2