From b7a4441f22fb1c55f706450cab439e75b7ec3e4c Mon Sep 17 00:00:00 2001 From: ngie Date: Sun, 22 May 2016 02:02:18 +0000 Subject: Don't leak `handle` if svc_tp_create(..) succeeds and allocating a new struct xlist object fails MFC after: 1 week Reported by: Coverity CID: 978277 Sponsored by: EMC / Isilon Storage Division --- lib/libc/rpc/svc_generic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/libc/rpc/svc_generic.c b/lib/libc/rpc/svc_generic.c index d3db612..00bbc5a 100644 --- a/lib/libc/rpc/svc_generic.c +++ b/lib/libc/rpc/svc_generic.c @@ -122,7 +122,8 @@ svc_create(void (*dispatch)(struct svc_req *, SVCXPRT *), if (l == NULL) { warnx("svc_create: no memory"); mutex_unlock(&xprtlist_lock); - return (0); + num = 0; + goto done; } l->xprt = xprt; l->next = xprtlist; @@ -132,6 +133,7 @@ svc_create(void (*dispatch)(struct svc_req *, SVCXPRT *), } mutex_unlock(&xprtlist_lock); } +done: __rpc_endconf(handle); /* * In case of num == 0; the error messages are generated by the -- cgit v1.1