diff options
author | kib <kib@FreeBSD.org> | 2012-04-28 18:57:27 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2012-04-28 18:57:27 +0000 |
commit | 3378e556f13cad9cb91bd3cfee7d6a9147202305 (patch) | |
tree | 52470c4e1134ce892fbc5c9b04bc5b30b0c35415 /lib/libc/rpc/svc.c | |
parent | f67b4d433308479a900040e4c5f3e54133015eed (diff) | |
download | FreeBSD-src-3378e556f13cad9cb91bd3cfee7d6a9147202305.zip FreeBSD-src-3378e556f13cad9cb91bd3cfee7d6a9147202305.tar.gz |
Fix several memory and lock leaks on the out of memory condition.
Reported by: Matt Miller <matt matthewjmiller net>
MFC after: 1 week
Diffstat (limited to 'lib/libc/rpc/svc.c')
-rw-r--r-- | lib/libc/rpc/svc.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/libc/rpc/svc.c b/lib/libc/rpc/svc.c index 282c2be..78a8ae1 100644 --- a/lib/libc/rpc/svc.c +++ b/lib/libc/rpc/svc.c @@ -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; |