Skip to contentSkip to conversation

SUNRPC: destroy freshly allocated transport in case of sockaddr init error

PATCH New Stanislav Kinsbursky 1 participant 1 message Nov 10, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SUNRPC: destroy freshly allocated transport in case of sockaddr init error

Otherwise we will leak xprt structure and struct net reference.

---
 net/sunrpc/xprtsock.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
net/sunrpc/xprtsock.c +3 -1
index d7f97ef..2d78d95 100644
@@ -2530,8 +2530,10 @@ static struct rpc_xprt *xs_setup_xprt(struct xprt_create *args,
 		int err;
 		err = xs_init_anyaddr(args->dstaddr->sa_family,
 					(struct sockaddr *)&new->srcaddr);
-		if (err != 0)
+		if (err != 0) {
+			xprt_free(xprt);
 			return ERR_PTR(err);
+		}
 	}
 
 	return xprt;