svc_tli_create: close memory leak xprt->xp_netid can be allocated by makefd_xprt() in svc_fd_create(), so don't blindly overwrite the pointer in svc_tli_create() The API expection is the nc_netid passed in will be used for the xp_netid. So the pointer must be freed then re-allocated. Reported-by: Michael Theall Signed-off-by: Steve Dickson diff --git a/lib/libc/rpc/svc_generic.c b/lib/libc/rpc/svc_generic.c index ade7ea1bcd8a..5ab4b2bebb73 100644 --- a/lib/libc/rpc/svc_generic.c +++ b/lib/libc/rpc/svc_generic.c @@ -298,6 +298,8 @@ svc_tli_create(int fd, const struct netconfig *nconf, xprt->xp_type = __rpc_socktype2seman(si.si_socktype); if (nconf) { + if (xprt->xp_netid != NULL) + free(xprt->xp_netid); xprt->xp_netid = strdup(nconf->nc_netid); xprt->xp_tp = strdup(nconf->nc_device); }