summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/kern_ktrace.c15
-rw-r--r--sys/kern/sys_process.c14
-rw-r--r--sys/kern/sysv_sem.c12
-rw-r--r--sys/kern/uipc_syscalls.c16
-rw-r--r--sys/kern/vfs_subr.c6
-rw-r--r--sys/kern/vfs_vnops.c4
6 files changed, 36 insertions, 31 deletions
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c
index 71fb296cef6..d0f68be1153 100644
--- a/sys/kern/kern_ktrace.c
+++ b/sys/kern/kern_ktrace.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_ktrace.c,v 1.67 2014/07/12 18:43:32 tedu Exp $ */
+/* $OpenBSD: kern_ktrace.c,v 1.68 2014/07/13 15:00:40 tedu Exp $ */
/* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */
/*
@@ -175,7 +175,7 @@ ktrsyscall(struct proc *p, register_t code, size_t argsize, register_t args[])
memset(argp, 0, nargs * sizeof(int));
kth.ktr_len = len;
ktrwrite(p, &kth, ktp);
- free(ktp, M_TEMP, 0);
+ free(ktp, M_TEMP, len);
atomic_clearbits_int(&p->p_flag, P_INKTR);
}
@@ -238,7 +238,7 @@ ktrgenio(struct proc *p, int fd, enum uio_rw rw, struct iovec *iov,
struct ktr_genio *ktp;
caddr_t cp;
int count;
- int buflen;
+ int mlen, buflen;
atomic_setbits_int(&p->p_flag, P_INKTR);
@@ -249,7 +249,8 @@ ktrgenio(struct proc *p, int fd, enum uio_rw rw, struct iovec *iov,
buflen = len + sizeof(struct ktr_genio);
ktrinitheader(&kth, p, KTR_GENIO);
- ktp = malloc(buflen, M_TEMP, M_WAITOK);
+ mlen = buflen;
+ ktp = malloc(mlen, M_TEMP, M_WAITOK);
ktp->ktr_fd = fd;
ktp->ktr_rw = rw;
@@ -284,7 +285,7 @@ ktrgenio(struct proc *p, int fd, enum uio_rw rw, struct iovec *iov,
len -= count;
}
- free(ktp, M_TEMP, 0);
+ free(ktp, M_TEMP, mlen);
atomic_clearbits_int(&p->p_flag, P_INKTR);
}
@@ -346,7 +347,7 @@ ktrstruct(struct proc *p, const char *name, const void *data, size_t datalen)
kth.ktr_len = buflen;
ktrwrite(p, &kth, buf);
- free(buf, M_TEMP, 0);
+ free(buf, M_TEMP, buflen);
atomic_clearbits_int(&p->p_flag, P_INKTR);
}
@@ -387,7 +388,7 @@ ktruser(struct proc *p, const char *id, const void *addr, size_t len)
ktrwrite(p, &kth, ktp);
out:
if (memp != NULL)
- free(memp, M_TEMP, 0);
+ free(memp, M_TEMP, sizeof(*ktp) + len);
atomic_clearbits_int(&p->p_flag, P_INKTR);
return (error);
}
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
index 53d7efec5ad..4bd359710e3 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_process.c,v 1.63 2014/07/12 18:43:32 tedu Exp $ */
+/* $OpenBSD: sys_process.c,v 1.64 2014/07/13 15:00:40 tedu Exp $ */
/* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */
/*-
@@ -581,7 +581,7 @@ sys_ptrace(struct proc *p, void *v, register_t *retval)
if (error == 0) {
error = process_write_regs(t, regs);
}
- free(regs, M_TEMP, 0);
+ free(regs, M_TEMP, sizeof(*regs));
return (error);
case PT_GETREGS:
KASSERT((p->p_flag & P_SYSTEM) == 0);
@@ -593,7 +593,7 @@ sys_ptrace(struct proc *p, void *v, register_t *retval)
if (error == 0)
error = copyout(regs,
SCARG(uap, addr), sizeof (*regs));
- free(regs, M_TEMP, 0);
+ free(regs, M_TEMP, sizeof(*regs));
return (error);
#ifdef PT_SETFPREGS
case PT_SETFPREGS:
@@ -606,7 +606,7 @@ sys_ptrace(struct proc *p, void *v, register_t *retval)
if (error == 0) {
error = process_write_fpregs(t, fpregs);
}
- free(fpregs, M_TEMP, 0);
+ free(fpregs, M_TEMP, sizeof(*fpregs));
return (error);
#endif
#ifdef PT_GETFPREGS
@@ -620,7 +620,7 @@ sys_ptrace(struct proc *p, void *v, register_t *retval)
if (error == 0)
error = copyout(fpregs,
SCARG(uap, addr), sizeof(*fpregs));
- free(fpregs, M_TEMP, 0);
+ free(fpregs, M_TEMP, sizeof(*fpregs));
return (error);
#endif
#ifdef PT_SETXMMREGS
@@ -634,7 +634,7 @@ sys_ptrace(struct proc *p, void *v, register_t *retval)
if (error == 0) {
error = process_write_xmmregs(t, xmmregs);
}
- free(xmmregs, M_TEMP, 0);
+ free(xmmregs, M_TEMP, sizeof(*xmmregs));
return (error);
#endif
#ifdef PT_GETXMMREGS
@@ -648,7 +648,7 @@ sys_ptrace(struct proc *p, void *v, register_t *retval)
if (error == 0)
error = copyout(xmmregs,
SCARG(uap, addr), sizeof(*xmmregs));
- free(xmmregs, M_TEMP, 0);
+ free(xmmregs, M_TEMP, sizeof(*xmmregs));
return (error);
#endif
#ifdef PT_WCOOKIE
diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c
index df3ddd3650a..d36b84524b7 100644
--- a/sys/kern/sysv_sem.c
+++ b/sys/kern/sysv_sem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysv_sem.c,v 1.47 2014/07/12 18:43:32 tedu Exp $ */
+/* $OpenBSD: sysv_sem.c,v 1.48 2014/07/13 15:00:40 tedu Exp $ */
/* $NetBSD: sysv_sem.c,v 1.26 1996/02/09 19:00:25 christos Exp $ */
/*
@@ -384,7 +384,8 @@ semctl1(struct proc *p, int semid, int semnum, int cmd, union semun *arg,
error:
if (semval)
- free(semval, M_TEMP, 0);
+ free(semval, M_TEMP,
+ semaptr->sem_nsems * sizeof(arg->array[0]));
return (error);
}
@@ -446,7 +447,8 @@ sys_semget(struct proc *p, void *v, register_t *retval)
goto error;
}
if (semaptr_new != NULL) {
- free(semaptr_new->sem_base, M_SEM, 0);
+ free(semaptr_new->sem_base, M_SEM,
+ nsems * sizeof(struct sem));
pool_put(&sema_pool, semaptr_new);
}
goto found;
@@ -489,7 +491,7 @@ found:
return (0);
error:
if (semaptr_new != NULL) {
- free(semaptr_new->sem_base, M_SEM, 0);
+ free(semaptr_new->sem_base, M_SEM, nsems * sizeof(struct sem));
pool_put(&sema_pool, semaptr_new);
}
return (error);
@@ -753,7 +755,7 @@ done:
*retval = 0;
done2:
if (sops != sopbuf)
- free(sops, M_SEM, 0);
+ free(sops, M_SEM, nsops * sizeof(struct sembuf));
return (error);
}
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 147dcb789b9..879e8096c47 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_syscalls.c,v 1.90 2014/07/12 18:43:32 tedu Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.91 2014/07/13 15:00:40 tedu Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
@@ -454,7 +454,7 @@ sys_sendmsg(struct proc *p, void *v, register_t *retval)
error = sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval);
done:
if (iov != aiov)
- free(iov, M_IOV, 0);
+ free(iov, M_IOV, sizeof(struct iovec) * msg.msg_iovlen);
return (error);
}
@@ -470,6 +470,7 @@ sendit(struct proc *p, int s, struct msghdr *mp, int flags, register_t *retsize)
int error;
#ifdef KTRACE
struct iovec *ktriov = NULL;
+ int iovlen = 0;
#endif
to = NULL;
@@ -515,7 +516,7 @@ sendit(struct proc *p, int s, struct msghdr *mp, int flags, register_t *retsize)
control = 0;
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO)) {
- int iovlen = auio.uio_iovcnt * sizeof (struct iovec);
+ iovlen = auio.uio_iovcnt * sizeof (struct iovec);
ktriov = malloc(iovlen, M_TEMP, M_WAITOK);
bcopy(auio.uio_iov, ktriov, iovlen);
@@ -539,7 +540,7 @@ sendit(struct proc *p, int s, struct msghdr *mp, int flags, register_t *retsize)
if (ktriov != NULL) {
if (error == 0)
ktrgenio(p, s, UIO_WRITE, ktriov, *retsize);
- free(ktriov, M_TEMP, 0);
+ free(ktriov, M_TEMP, iovlen);
}
#endif
bad:
@@ -619,7 +620,7 @@ sys_recvmsg(struct proc *p, void *v, register_t *retval)
}
done:
if (iov != aiov)
- free(iov, M_IOV, 0);
+ free(iov, M_IOV, sizeof(struct iovec) * msg.msg_iovlen);
return (error);
}
@@ -636,6 +637,7 @@ recvit(struct proc *p, int s, struct msghdr *mp, caddr_t namelenp,
struct mbuf *from = NULL, *control = NULL;
#ifdef KTRACE
struct iovec *ktriov = NULL;
+ int iovlen = 0;
#endif
if ((error = getsock(p->p_fd, s, &fp)) != 0)
@@ -658,7 +660,7 @@ recvit(struct proc *p, int s, struct msghdr *mp, caddr_t namelenp,
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO)) {
- int iovlen = auio.uio_iovcnt * sizeof (struct iovec);
+ iovlen = auio.uio_iovcnt * sizeof (struct iovec);
ktriov = malloc(iovlen, M_TEMP, M_WAITOK);
bcopy(auio.uio_iov, ktriov, iovlen);
@@ -678,7 +680,7 @@ recvit(struct proc *p, int s, struct msghdr *mp, caddr_t namelenp,
if (ktriov != NULL) {
if (error == 0)
ktrgenio(p, s, UIO_READ, ktriov, len - auio.uio_resid);
- free(ktriov, M_TEMP, 0);
+ free(ktriov, M_TEMP, iovlen);
}
#endif
if (error)
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index b97b497f821..a26fbe2e851 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_subr.c,v 1.217 2014/07/12 18:43:32 tedu Exp $ */
+/* $OpenBSD: vfs_subr.c,v 1.218 2014/07/13 15:00:40 tedu Exp $ */
/* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */
/*
@@ -1066,7 +1066,7 @@ vgonel(struct vnode *vp, struct proc *p)
vx->v_flag &= ~VALIASED;
vp->v_flag &= ~VALIASED;
}
- free(vp->v_specinfo, M_VNODE, 0);
+ free(vp->v_specinfo, M_VNODE, sizeof(struct specinfo));
vp->v_specinfo = NULL;
}
/*
@@ -1281,7 +1281,7 @@ vfs_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
ret = sysctl_rdstruct(oldp, oldlenp, newp, tmpvfsp,
sizeof(struct vfsconf));
- free(tmpvfsp, M_TEMP, 0);
+ free(tmpvfsp, M_TEMP, sizeof(*tmpvfsp));
return (ret);
case VFS_BCACHESTAT: /* buffer cache statistics */
ret = sysctl_rdstruct(oldp, oldlenp, newp, &bcstats,
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 0ea3035563a..a550743e45a 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_vnops.c,v 1.77 2014/07/12 18:43:32 tedu Exp $ */
+/* $OpenBSD: vfs_vnops.c,v 1.78 2014/07/13 15:00:40 tedu Exp $ */
/* $NetBSD: vfs_vnops.c,v 1.20 1996/02/04 02:18:41 christos Exp $ */
/*
@@ -173,7 +173,7 @@ vn_open(struct nameidata *ndp, int fmode, int cmode)
VOP_UNLOCK(vp, 0, p); /* keep a reference */
vp = ndp->ni_vp; /* for the increment below */
- free(cip, M_TEMP, 0);
+ free(cip, M_TEMP, sizeof(*cip));
}
if (fmode & FWRITE)