sunrpc: release svc_pool_map reference when serv allocation fails
authorJeff Layton <jlayton@primarydata.com>
Wed, 19 Nov 2014 12:51:13 +0000 (07:51 -0500)
committerJ. Bruce Fields <bfields@redhat.com>
Mon, 1 Dec 2014 19:45:27 +0000 (12:45 -0700)
Currently, it leaks when the allocation fails.

Signed-off-by: Jeff Layton <jlayton@primarydata.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
net/sunrpc/svc.c

index 349c98f9818b3c841f07a4af44fecaad03039c89..537add5309cc4c978bf03af88014ba10521bf90d 100644 (file)
@@ -503,13 +503,15 @@ svc_create_pooled(struct svc_program *prog, unsigned int bufsize,
        unsigned int npools = svc_pool_map_get();
 
        serv = __svc_create(prog, bufsize, npools, shutdown);
+       if (!serv)
+               goto out_err;
 
-       if (serv != NULL) {
-               serv->sv_function = func;
-               serv->sv_module = mod;
-       }
-
+       serv->sv_function = func;
+       serv->sv_module = mod;
        return serv;
+out_err:
+       svc_pool_map_put();
+       return NULL;
 }
 EXPORT_SYMBOL_GPL(svc_create_pooled);