From owner-svn-src-stable@FreeBSD.ORG Sat May 5 00:28:09 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 052F41065670; Sat, 5 May 2012 00:28:09 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CB22A8FC14; Sat, 5 May 2012 00:28:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q450S8lA029835; Sat, 5 May 2012 00:28:08 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q450S8MU029832; Sat, 5 May 2012 00:28:08 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201205050028.q450S8MU029832@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 5 May 2012 00:28:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235045 - stable/9/lib/libc/rpc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 May 2012 00:28:09 -0000 Author: kib Date: Sat May 5 00:28:08 2012 New Revision: 235045 URL: http://svn.freebsd.org/changeset/base/235045 Log: MFC r234769: Fix several memory and lock leaks on the out of memory condition. Modified: stable/9/lib/libc/rpc/svc.c stable/9/lib/libc/rpc/svc_raw.c Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/rpc/svc.c ============================================================================== --- stable/9/lib/libc/rpc/svc.c Sat May 5 00:08:05 2012 (r235044) +++ stable/9/lib/libc/rpc/svc.c Sat May 5 00:28:08 2012 (r235045) @@ -108,8 +108,10 @@ xprt_register(xprt) if (__svc_xports == NULL) { __svc_xports = (SVCXPRT **) mem_alloc(FD_SETSIZE * sizeof(SVCXPRT *)); - if (__svc_xports == NULL) + if (__svc_xports == NULL) { + rwlock_unlock(&svc_fd_lock); return; + } memset(__svc_xports, '\0', FD_SETSIZE * sizeof(SVCXPRT *)); } if (sock < FD_SETSIZE) { @@ -565,8 +567,14 @@ svc_xprt_alloc() SVCXPRT_EXT *ext; xprt = mem_alloc(sizeof(SVCXPRT)); + if (xprt == NULL) + return (NULL); memset(xprt, 0, sizeof(SVCXPRT)); ext = mem_alloc(sizeof(SVCXPRT_EXT)); + if (ext == NULL) { + mem_free(xprt, sizeof(SVCXPRT)); + return (NULL); + } memset(ext, 0, sizeof(SVCXPRT_EXT)); xprt->xp_p3 = ext; ext->xp_auth.svc_ah_ops = &svc_auth_null_ops; Modified: stable/9/lib/libc/rpc/svc_raw.c ============================================================================== --- stable/9/lib/libc/rpc/svc_raw.c Sat May 5 00:08:05 2012 (r235044) +++ stable/9/lib/libc/rpc/svc_raw.c Sat May 5 00:28:08 2012 (r235045) @@ -96,10 +96,22 @@ svc_raw_create() mutex_unlock(&svcraw_lock); return (NULL); } - if (__rpc_rawcombuf == NULL) + if (__rpc_rawcombuf == NULL) { __rpc_rawcombuf = calloc(UDPMSGSIZE, sizeof (char)); + if (__rpc_rawcombuf == NULL) { + free(srp); + mutex_unlock(&svcraw_lock); + return (NULL); + } + } srp->raw_buf = __rpc_rawcombuf; /* Share it with the client */ srp->server = svc_xprt_alloc(); + if (srp->server == NULL) { + free(__rpc_rawcombuf); + free(srp); + mutex_unlock(&svcraw_lock); + return (NULL); + } svc_raw_private = srp; } srp->server->xp_fd = FD_SETSIZE;