Mon Jul 30 10:45:03 2012 UTC ()
remove infinite loop on error, extra parens on return.


(christos)
diff -r1.138 -r1.139 src/sys/kern/uipc_usrreq.c

cvs diff -r1.138 -r1.139 src/sys/kern/uipc_usrreq.c (expand / switch to unified diff)

--- src/sys/kern/uipc_usrreq.c 2012/07/30 10:42:24 1.138
+++ src/sys/kern/uipc_usrreq.c 2012/07/30 10:45:03 1.139
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: uipc_usrreq.c,v 1.138 2012/07/30 10:42:24 christos Exp $ */ 1/* $NetBSD: uipc_usrreq.c,v 1.139 2012/07/30 10:45:03 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998, 2000, 2004, 2008, 2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998, 2000, 2004, 2008, 2009 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center, and by Andrew Doran. 9 * NASA Ames Research Center, and by Andrew Doran.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -86,27 +86,27 @@ @@ -86,27 +86,27 @@
86 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 86 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
87 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 87 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
88 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 88 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
89 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 89 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
90 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 90 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
91 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 91 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
92 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 92 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
93 * SUCH DAMAGE. 93 * SUCH DAMAGE.
94 * 94 *
95 * @(#)uipc_usrreq.c 8.9 (Berkeley) 5/14/95 95 * @(#)uipc_usrreq.c 8.9 (Berkeley) 5/14/95
96 */ 96 */
97 97
98#include <sys/cdefs.h> 98#include <sys/cdefs.h>
99__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.138 2012/07/30 10:42:24 christos Exp $"); 99__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.139 2012/07/30 10:45:03 christos Exp $");
100 100
101#include <sys/param.h> 101#include <sys/param.h>
102#include <sys/systm.h> 102#include <sys/systm.h>
103#include <sys/proc.h> 103#include <sys/proc.h>
104#include <sys/filedesc.h> 104#include <sys/filedesc.h>
105#include <sys/domain.h> 105#include <sys/domain.h>
106#include <sys/protosw.h> 106#include <sys/protosw.h>
107#include <sys/socket.h> 107#include <sys/socket.h>
108#include <sys/socketvar.h> 108#include <sys/socketvar.h>
109#include <sys/unpcb.h> 109#include <sys/unpcb.h>
110#include <sys/un.h> 110#include <sys/un.h>
111#include <sys/namei.h> 111#include <sys/namei.h>
112#include <sys/vnode.h> 112#include <sys/vnode.h>
@@ -1331,32 +1331,31 @@ unp_externalize(struct mbuf *rights, str @@ -1331,32 +1331,31 @@ unp_externalize(struct mbuf *rights, str
1331 */ 1331 */
1332 if (sizeof(file_t *) != sizeof(int)) { 1332 if (sizeof(file_t *) != sizeof(int)) {
1333 cm->cmsg_len = CMSG_LEN(nfds * sizeof(int)); 1333 cm->cmsg_len = CMSG_LEN(nfds * sizeof(int));
1334 rights->m_len = CMSG_SPACE(nfds * sizeof(int)); 1334 rights->m_len = CMSG_SPACE(nfds * sizeof(int));
1335 } 1335 }
1336 out: 1336 out:
1337 if (__predict_false(error != 0)) { 1337 if (__predict_false(error != 0)) {
1338 rp = (file_t **)CMSG_DATA(cm); 1338 rp = (file_t **)CMSG_DATA(cm);
1339 for (size_t i = 0; i < nfds; i++) { 1339 for (size_t i = 0; i < nfds; i++) {
1340 file_t * const fp = *rp; 1340 file_t * const fp = *rp;
1341 *rp++ = 0; 1341 *rp++ = 0;
1342 unp_discard_now(fp); 1342 unp_discard_now(fp);
1343 } 1343 }
1344 goto out; 
1345 } 1344 }
1346 1345
1347 rw_exit(&p->p_cwdi->cwdi_lock); 1346 rw_exit(&p->p_cwdi->cwdi_lock);
1348 kmem_free(fdp, nfds * sizeof(int)); 1347 kmem_free(fdp, nfds * sizeof(int));
1349 return (error); 1348 return error;
1350} 1349}
1351 1350
1352int 1351int
1353unp_internalize(struct mbuf **controlp) 1352unp_internalize(struct mbuf **controlp)
1354{ 1353{
1355 filedesc_t *fdescp = curlwp->l_fd; 1354 filedesc_t *fdescp = curlwp->l_fd;
1356 struct mbuf *control = *controlp; 1355 struct mbuf *control = *controlp;
1357 struct cmsghdr *newcm, *cm = mtod(control, struct cmsghdr *); 1356 struct cmsghdr *newcm, *cm = mtod(control, struct cmsghdr *);
1358 file_t **rp, **files; 1357 file_t **rp, **files;
1359 file_t *fp; 1358 file_t *fp;
1360 int i, fd, *fdp; 1359 int i, fd, *fdp;
1361 int nfds, error; 1360 int nfds, error;
1362 u_int maxmsg; 1361 u_int maxmsg;