Skip to contentSkip to conversation

nfsd: return err directly while allocing failing

PATCH RESEND In review Rui Xiang 2 participants 2 messages Dec 9, 2013 – Jan 6, 2014

Subsystems (2)
lore
Share & tools
lore

Rui Xiang

author
#0 lore raw

PATCH RESEND 1/1 nfsd: return err directly while allocing failing

while nthreads alloc fails, return err value directly without kfree.

---
 fs/nfsd/nfsctl.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
fs/nfsd/nfsctl.c +4 -3
index 7f55517..1fa6b00 100644
@@ -491,9 +491,10 @@ static ssize_t write_pool_threads(struct file *file, char *buf, size_t size)
 	}
 
 	nthreads = kcalloc(npools, sizeof(int), GFP_KERNEL);
-	rv = -ENOMEM;
-	if (nthreads == NULL)
-		goto out_free;
+	if (nthreads == NULL) {
+		mutex_unlock(&nfsd_mutex);
+		return -ENOMEM;
+	}
 
 	if (size > 0) {
 		for (i = 0; i < npools; i++) {
Signature · 1 line
1.8.2.2
#1 lore raw
Quoted 2 lines · Rui Xiang

while nthreads alloc fails, return err value directly without kfree.

This doesn't fix any problem that I can see, since kfree(NULL) is defined to be a no-op.

--b.

Quoted 28 lines
---
 fs/nfsd/nfsctl.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
fs/nfsd/nfsctl.c +4 -3
index 7f55517..1fa6b00 100644
@@ -491,9 +491,10 @@ static ssize_t write_pool_threads(struct file *file, char *buf, size_t size)
 	}
 
 	nthreads = kcalloc(npools, sizeof(int), GFP_KERNEL);
-	rv = -ENOMEM;
-	if (nthreads == NULL)
-		goto out_free;
+	if (nthreads == NULL) {
+		mutex_unlock(&nfsd_mutex);
+		return -ENOMEM;
+	}
 
 	if (size > 0) {
 		for (i = 0; i < npools; i++) {
Signature · 1 line
1.8.2.2