]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
SUNRPC: fix xprt leak on xps allocation failure
authorJ. Bruce Fields <bfields@redhat.com>
Fri, 20 May 2016 21:07:17 +0000 (17:07 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Jul 2016 15:42:12 +0000 (08:42 -0700)
commit 1208fd569c07ab84aa5d024abd863267c2953b4a upstream.

Callers of rpc_create_xprt expect it to put the xprt on success and
failure.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Acked-by: Trond Myklebust <trondmy@primarydata.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/sunrpc/clnt.c

index 3d7eebd3b713e012b3e82298e62314b9a66360c3..ad3f5ebec2d126dfc695dd40f7fada1dd5f00158 100644 (file)
@@ -453,9 +453,10 @@ static struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args,
        struct rpc_xprt_switch *xps;
 
        xps = xprt_switch_alloc(xprt, GFP_KERNEL);
-       if (xps == NULL)
+       if (xps == NULL) {
+               xprt_put(xprt);
                return ERR_PTR(-ENOMEM);
-
+       }
        clnt = rpc_new_client(args, xps, xprt, NULL);
        if (IS_ERR(clnt))
                return clnt;