Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Replace M_IOV and some malloc(9)s with kmem(9), and whil...
details: https://anonhg.NetBSD.org/src/rev/377b2e2e6447
branches: trunk
changeset: 754195:377b2e2e6447
user: rmind <rmind%NetBSD.org@localhost>
date: Fri Apr 23 15:19:19 2010 +0000
description:
Replace M_IOV and some malloc(9)s with kmem(9), and while there:
- Fix invalid free (M_TEMP vs M_IOV) in do_sys_recvmsg(), spotted by jakllsch@.
Also, same fix in osf1_sys_sendmsg_xopen().
- Fix attempt to free non-allocated memory in error path in netbsd32___getfh30().
- Plug a memory leak in compat_43_netbsd32_orecvmsg().
diffstat:
sys/compat/netbsd32/netbsd32_compat_10.c | 5 +-
sys/compat/netbsd32/netbsd32_compat_20.c | 5 +-
sys/compat/netbsd32/netbsd32_compat_30.c | 13 ++--
sys/compat/netbsd32/netbsd32_compat_43.c | 16 +++--
sys/compat/netbsd32/netbsd32_compat_50.c | 12 +--
sys/compat/netbsd32/netbsd32_event.c | 11 +--
sys/compat/netbsd32/netbsd32_exec_aout.c | 5 +-
sys/compat/netbsd32/netbsd32_fs.c | 33 ++++++------
sys/compat/netbsd32/netbsd32_ioctl.c | 7 +-
sys/compat/netbsd32/netbsd32_netbsd.c | 33 +++++++-----
sys/compat/netbsd32/netbsd32_select.c | 5 +-
sys/compat/netbsd32/netbsd32_signal.c | 5 +-
sys/compat/netbsd32/netbsd32_socket.c | 50 ++++++++----------
sys/compat/netbsd32/netbsd32_sysctl.c | 5 +-
sys/compat/osf1/osf1_cvt.c | 5 +-
sys/compat/osf1/osf1_descrip.c | 5 +-
sys/compat/osf1/osf1_file.c | 10 +-
sys/compat/osf1/osf1_generic.c | 16 ++---
sys/compat/osf1/osf1_misc.c | 5 +-
sys/compat/osf1/osf1_signal.c | 5 +-
sys/compat/osf1/osf1_socket.c | 19 ++----
sys/kern/uipc_syscalls.c | 82 ++++++++++---------------------
sys/sys/uio.h | 8 +-
23 files changed, 153 insertions(+), 207 deletions(-)
diffs (truncated from 1235 to 300 lines):
diff -r 86a36a4fd622 -r 377b2e2e6447 sys/compat/netbsd32/netbsd32_compat_10.c
--- a/sys/compat/netbsd32/netbsd32_compat_10.c Fri Apr 23 15:04:09 2010 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_10.c Fri Apr 23 15:19:19 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_compat_10.c,v 1.23 2009/01/11 02:45:49 christos Exp $ */
+/* $NetBSD: netbsd32_compat_10.c,v 1.24 2010/04/23 15:19:20 rmind Exp $ */
/*
* Copyright (c) 1994 Adam Glass and Charles M. Hannum. All rights reserved.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_10.c,v 1.23 2009/01/11 02:45:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_10.c,v 1.24 2010/04/23 15:19:20 rmind Exp $");
#ifdef _KERNEL_OPT
#include "opt_sysv.h"
@@ -42,7 +42,6 @@
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/sem.h>
-#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
diff -r 86a36a4fd622 -r 377b2e2e6447 sys/compat/netbsd32/netbsd32_compat_20.c
--- a/sys/compat/netbsd32/netbsd32_compat_20.c Fri Apr 23 15:04:09 2010 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_20.c Fri Apr 23 15:19:19 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_compat_20.c,v 1.27 2009/06/29 05:08:16 dholland Exp $ */
+/* $NetBSD: netbsd32_compat_20.c,v 1.28 2010/04/23 15:19:20 rmind Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,11 +27,10 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_20.c,v 1.27 2009/06/29 05:08:16 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_20.c,v 1.28 2010/04/23 15:19:20 rmind Exp $");
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/time.h>
diff -r 86a36a4fd622 -r 377b2e2e6447 sys/compat/netbsd32/netbsd32_compat_30.c
--- a/sys/compat/netbsd32/netbsd32_compat_30.c Fri Apr 23 15:04:09 2010 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_30.c Fri Apr 23 15:19:19 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_compat_30.c,v 1.29 2009/01/26 13:00:04 njoly Exp $ */
+/* $NetBSD: netbsd32_compat_30.c,v 1.30 2010/04/23 15:19:20 rmind Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,11 +27,10 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_30.c,v 1.29 2009/01/26 13:00:04 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_30.c,v 1.30 2010/04/23 15:19:20 rmind Exp $");
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
@@ -79,13 +78,13 @@
error = EBADF;
goto out;
}
- buf = malloc(count, M_TEMP, M_WAITOK);
+ buf = kmem_alloc(count, KM_SLEEP);
error = vn_readdir(fp, buf, UIO_SYSSPACE, count, &done, l, 0, 0);
if (error == 0) {
*retval = netbsd32_to_dirent12(buf, done);
error = copyout(buf, SCARG_P32(uap, buf), *retval);
}
- free(buf, M_TEMP);
+ kmem_free(buf, count);
out:
fd_putfile(SCARG(uap, fd));
return (error);
@@ -210,10 +209,10 @@
SCARG(uap, flags));
if (error != 0) {
- s32 = malloc(sizeof *s32, M_TEMP, M_WAITOK);
+ s32 = kmem_alloc(sizeof(*s32), KM_SLEEP);
netbsd32_from_statvfs(sbuf, s32);
error = copyout(s32, SCARG_P32(uap, buf), sizeof *s32);
- free(s32, M_TEMP);
+ kmem_free(s32, sizeof(*s32));
}
STATVFSBUF_PUT(sbuf);
diff -r 86a36a4fd622 -r 377b2e2e6447 sys/compat/netbsd32/netbsd32_compat_43.c
--- a/sys/compat/netbsd32/netbsd32_compat_43.c Fri Apr 23 15:04:09 2010 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_43.c Fri Apr 23 15:19:19 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_compat_43.c,v 1.51 2009/01/30 13:01:36 njoly Exp $ */
+/* $NetBSD: netbsd32_compat_43.c,v 1.52 2010/04/23 15:19:20 rmind Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_43.c,v 1.51 2009/01/30 13:01:36 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_43.c,v 1.52 2010/04/23 15:19:20 rmind Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_43.h"
@@ -37,7 +37,6 @@
#include <sys/systm.h>
#include <sys/fcntl.h>
#include <sys/filedesc.h>
-#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/mount.h>
#include <sys/namei.h>
@@ -456,7 +455,7 @@
NETBSD32PTR64(omsg.msg_accrights) != NULL ? &control : NULL,
retval);
if (error != 0)
- return error;
+ goto out;
/*
* If there is any control information and it's SCM_RIGHTS,
@@ -493,7 +492,10 @@
if (error != 0)
error = copyout(&omsg, SCARG_P32(uap, msg), sizeof(omsg));
-
+out:
+ if (iov != aiov) {
+ kmem_free(iov, omsg.msg_iovlen * sizeof(struct iov));
+ }
return error;
}
@@ -508,10 +510,10 @@
struct iovec *iov, aiov[UIO_SMALLIOV];
struct netbsd32_omsghdr omsg;
struct msghdr msg;
- int error;
struct mbuf *nam;
struct osockaddr *osa;
struct sockaddr *sa;
+ int error;
error = copyin(SCARG_P32(uap, msg), &omsg, sizeof (struct omsghdr));
if (error != 0)
@@ -549,7 +551,7 @@
out:
if (iov != aiov)
- free(iov, M_TEMP);
+ kmem_free(iov, omsg.msg_iovlen * sizeof(struct iov));
return (error);
}
diff -r 86a36a4fd622 -r 377b2e2e6447 sys/compat/netbsd32/netbsd32_compat_50.c
--- a/sys/compat/netbsd32/netbsd32_compat_50.c Fri Apr 23 15:04:09 2010 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_50.c Fri Apr 23 15:19:19 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_compat_50.c,v 1.15 2010/04/08 11:51:14 njoly Exp $ */
+/* $NetBSD: netbsd32_compat_50.c,v 1.16 2010/04/23 15:19:20 rmind Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.15 2010/04/08 11:51:14 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_50.c,v 1.16 2010/04/23 15:19:20 rmind Exp $");
#if defined(_KERNEL_OPT)
#include "opt_sysv.h"
@@ -44,7 +44,6 @@
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
@@ -630,17 +629,16 @@
nevents = SCARG(uap, nevents);
maxalloc = MIN(KQ_NEVENTS, MAX(nchanges, nevents));
netbsd32_kevent_ops.keo_private =
- malloc(maxalloc * sizeof(struct netbsd32_kevent), M_TEMP,
- M_WAITOK);
+ kmem_alloc(maxalloc * sizeof(struct netbsd32_kevent), KM_SLEEP);
error = kevent1(retval, SCARG(uap, fd),
NETBSD32PTR64(SCARG(uap, changelist)), nchanges,
NETBSD32PTR64(SCARG(uap, eventlist)), nevents,
NETBSD32PTR64(SCARG(uap, timeout)), &netbsd32_kevent_ops);
- free(netbsd32_kevent_ops.keo_private, M_TEMP);
+ kmem_free(netbsd32_kevent_ops.keo_private,
+ maxalloc * sizeof(struct netbsd32_kevent));
return error;
- return 0;
}
int
diff -r 86a36a4fd622 -r 377b2e2e6447 sys/compat/netbsd32/netbsd32_event.c
--- a/sys/compat/netbsd32/netbsd32_event.c Fri Apr 23 15:04:09 2010 +0000
+++ b/sys/compat/netbsd32/netbsd32_event.c Fri Apr 23 15:19:19 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_event.c,v 1.7 2009/01/11 02:45:49 christos Exp $ */
+/* $NetBSD: netbsd32_event.c,v 1.8 2010/04/23 15:19:20 rmind Exp $ */
/*
* Copyright (c) 2005 The NetBSD Foundation.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_event.c,v 1.7 2009/01/11 02:45:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_event.c,v 1.8 2010/04/23 15:19:20 rmind Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -37,7 +37,6 @@
#include <sys/select.h>
#include <sys/event.h>
#include <sys/eventvar.h>
-#include <sys/malloc.h>
#include <sys/proc.h>
#include <sys/dirent.h>
@@ -115,14 +114,14 @@
nevents = SCARG(uap, nevents);
maxalloc = MIN(KQ_NEVENTS, MAX(nchanges, nevents));
netbsd32_kevent_ops.keo_private =
- malloc(maxalloc * sizeof(struct netbsd32_kevent), M_TEMP,
- M_WAITOK);
+ kmem_alloc(maxalloc * sizeof(struct netbsd32_kevent), KM_SLEEP);
error = kevent1(retval, SCARG(uap, fd),
NETBSD32PTR64(SCARG(uap, changelist)), nchanges,
NETBSD32PTR64(SCARG(uap, eventlist)), nevents,
NETBSD32PTR64(SCARG(uap, timeout)), &netbsd32_kevent_ops);
- free(netbsd32_kevent_ops.keo_private, M_TEMP);
+ kmem_free(netbsd32_kevent_ops.keo_private,
+ maxalloc * sizeof(struct netbsd32_kevent));
return error;
}
diff -r 86a36a4fd622 -r 377b2e2e6447 sys/compat/netbsd32/netbsd32_exec_aout.c
--- a/sys/compat/netbsd32/netbsd32_exec_aout.c Fri Apr 23 15:04:09 2010 +0000
+++ b/sys/compat/netbsd32/netbsd32_exec_aout.c Fri Apr 23 15:19:19 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_exec_aout.c,v 1.24 2008/05/29 14:51:26 mrg Exp $ */
+/* $NetBSD: netbsd32_exec_aout.c,v 1.25 2010/04/23 15:19:20 rmind Exp $ */
/* from: NetBSD: exec_aout.c,v 1.15 1996/09/26 23:34:46 cgd Exp */
/*
@@ -57,12 +57,11 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_exec_aout.c,v 1.24 2008/05/29 14:51:26 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_exec_aout.c,v 1.25 2010/04/23 15:19:20 rmind Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
-#include <sys/malloc.h>
#include <sys/vnode.h>
#include <sys/exec.h>
#include <sys/exec_aout.h>
diff -r 86a36a4fd622 -r 377b2e2e6447 sys/compat/netbsd32/netbsd32_fs.c
--- a/sys/compat/netbsd32/netbsd32_fs.c Fri Apr 23 15:04:09 2010 +0000
+++ b/sys/compat/netbsd32/netbsd32_fs.c Fri Apr 23 15:19:19 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_fs.c,v 1.58 2009/12/14 00:47:11 matt Exp $ */
+/* $NetBSD: netbsd32_fs.c,v 1.59 2010/04/23 15:19:20 rmind Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,11 +27,10 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.58 2009/12/14 00:47:11 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_fs.c,v 1.59 2010/04/23 15:19:20 rmind Exp $");
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/malloc.h>
Home |
Main Index |
Thread Index |
Old Index