-/* $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 $ */
/*
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);
}
struct ktr_genio *ktp;
caddr_t cp;
int count;
- int buflen;
+ int mlen, buflen;
atomic_setbits_int(&p->p_flag, P_INKTR);
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;
len -= count;
}
- free(ktp, M_TEMP, 0);
+ free(ktp, M_TEMP, mlen);
atomic_clearbits_int(&p->p_flag, P_INKTR);
}
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);
}
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);
}
-/* $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 $ */
/*-
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);
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:
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
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
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
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
-/* $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 $ */
/*
error:
if (semval)
- free(semval, M_TEMP, 0);
+ free(semval, M_TEMP,
+ semaptr->sem_nsems * sizeof(arg->array[0]));
return (error);
}
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;
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);
*retval = 0;
done2:
if (sops != sopbuf)
- free(sops, M_SEM, 0);
+ free(sops, M_SEM, nsops * sizeof(struct sembuf));
return (error);
}
-/* $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 $ */
/*
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);
}
int error;
#ifdef KTRACE
struct iovec *ktriov = NULL;
+ int iovlen = 0;
#endif
to = NULL;
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);
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:
}
done:
if (iov != aiov)
- free(iov, M_IOV, 0);
+ free(iov, M_IOV, sizeof(struct iovec) * msg.msg_iovlen);
return (error);
}
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)
}
#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);
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)
-/* $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 $ */
/*
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;
}
/*
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,
-/* $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 $ */
/*
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)