From: tedu Date: Sat, 12 Jul 2014 18:50:00 +0000 (+0000) Subject: add a size argument to free. will be used soon, but for now default to 0. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0e5ae731040c42e0ae2549d149ca35cd27a051b5;p=openbsd add a size argument to free. will be used soon, but for now default to 0. after discussions with beck deraadt kettenis. --- diff --git a/sys/compat/common/compat_dir.c b/sys/compat/common/compat_dir.c index 7e8c2911a74..c2be83159ef 100644 --- a/sys/compat/common/compat_dir.c +++ b/sys/compat/common/compat_dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: compat_dir.c,v 1.8 2014/01/15 05:31:51 deraadt Exp $ */ +/* $OpenBSD: compat_dir.c,v 1.9 2014/07/12 18:50:00 tedu Exp $ */ /* * Copyright (c) 2000 Constantine Sapuntzakis @@ -71,7 +71,7 @@ readdir_with_callback(struct file *fp, off_t *off, u_long nbytes, buf = malloc(buflen, M_TEMP, M_WAITOK); error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curproc); if (error) { - free(buf, M_TEMP); + free(buf, M_TEMP, 0); return (error); } @@ -124,6 +124,6 @@ again: eof: out: VOP_UNLOCK(vp, 0, curproc); - free(buf, M_TEMP); + free(buf, M_TEMP, 0); return (error); } diff --git a/sys/compat/common/compat_util.c b/sys/compat/common/compat_util.c index 4bc1cb4dadd..f1cc4414fe6 100644 --- a/sys/compat/common/compat_util.c +++ b/sys/compat/common/compat_util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: compat_util.c,v 1.12 2014/03/26 05:23:42 guenther Exp $ */ +/* $OpenBSD: compat_util.c,v 1.13 2014/07/12 18:50:00 tedu Exp $ */ /* $NetBSD: compat_util.c,v 1.4 1996/03/14 19:31:45 christos Exp $ */ /* @@ -154,7 +154,7 @@ emul_find(struct proc *p, caddr_t *sgp, const char *prefix, *pbuf = path; goto bad; } - free(buf, M_TEMP); + free(buf, M_TEMP, 0); } vrele(nd.ni_vp); @@ -167,7 +167,7 @@ bad3: bad2: vrele(nd.ni_vp); bad: - free(buf, M_TEMP); + free(buf, M_TEMP, 0); return error; } diff --git a/sys/compat/linux/linux_exec.c b/sys/compat/linux/linux_exec.c index 919fe63c7f8..d8b592f917d 100644 --- a/sys/compat/linux/linux_exec.c +++ b/sys/compat/linux/linux_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_exec.c,v 1.41 2014/03/26 05:23:42 guenther Exp $ */ +/* $OpenBSD: linux_exec.c,v 1.42 2014/07/12 18:50:00 tedu Exp $ */ /* $NetBSD: linux_exec.c,v 1.13 1996/04/05 00:01:10 christos Exp $ */ /*- @@ -154,7 +154,7 @@ linux_e_proc_exit(struct proc *p) } /* free Linux emuldata and set the pointer to null */ - free(p->p_emuldata, M_EMULDATA); + free(p->p_emuldata, M_EMULDATA, 0); p->p_emuldata = NULL; } @@ -228,7 +228,7 @@ recognized: if ((error = emul_find(p, NULL, linux_emul_path, itp, &bp, 0))) return (error); error = copystr(bp, itp, MAXPATHLEN, &len); - free(bp, M_TEMP); + free(bp, M_TEMP, 0); if (error) return (error); } diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index 7f730e5c55e..cfc0906cc37 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_socket.c,v 1.52 2014/04/07 10:04:17 mpi Exp $ */ +/* $OpenBSD: linux_socket.c,v 1.53 2014/07/12 18:50:00 tedu Exp $ */ /* $NetBSD: linux_socket.c,v 1.14 1996/04/05 00:01:50 christos Exp $ */ /* @@ -1381,7 +1381,7 @@ linux_sa_get(p, sgp, sap, osa, osalen) out: *osalen = alloclen; - free(kosa, M_TEMP); + free(kosa, M_TEMP, 0); return (error); } diff --git a/sys/crypto/crypto.c b/sys/crypto/crypto.c index 7b531b0b726..021fa1c1f72 100644 --- a/sys/crypto/crypto.c +++ b/sys/crypto/crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.c,v 1.63 2014/01/21 05:40:32 mikeb Exp $ */ +/* $OpenBSD: crypto.c,v 1.64 2014/07/12 18:50:00 tedu Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) * @@ -266,7 +266,7 @@ crypto_get_driverid(u_int8_t flags) newdrv[i].cc_flags = flags; crypto_drivers_num *= 2; - free(crypto_drivers, M_CRYPTO_DATA); + free(crypto_drivers, M_CRYPTO_DATA, 0); crypto_drivers = newdrv; splx(s); return i; diff --git a/sys/crypto/cryptodev.c b/sys/crypto/cryptodev.c index 721a8f133c3..67713ae0f91 100644 --- a/sys/crypto/cryptodev.c +++ b/sys/crypto/cryptodev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cryptodev.c,v 1.80 2012/10/28 21:26:11 mikeb Exp $ */ +/* $OpenBSD: cryptodev.c,v 1.81 2014/07/12 18:50:00 tedu Exp $ */ /* * Copyright (c) 2001 Theo de Raadt @@ -268,11 +268,11 @@ bail: if (error) { if (crie.cri_key) { explicit_bzero(crie.cri_key, crie.cri_klen / 8); - free(crie.cri_key, M_XDATA); + free(crie.cri_key, M_XDATA, 0); } if (cria.cri_key) { explicit_bzero(cria.cri_key, cria.cri_klen / 8); - free(cria.cri_key, M_XDATA); + free(cria.cri_key, M_XDATA, 0); } } break; @@ -586,10 +586,10 @@ fail: if (krp->krp_param[i].crp_p) { explicit_bzero(krp->krp_param[i].crp_p, (krp->krp_param[i].crp_nbits + 7) / 8); - free(krp->krp_param[i].crp_p, M_XDATA); + free(krp->krp_param[i].crp_p, M_XDATA, 0); } } - free(krp, M_XDATA); + free(krp, M_XDATA, 0); } return (error); } @@ -626,7 +626,7 @@ cryptof_close(struct file *fp, struct proc *p) TAILQ_REMOVE(&fcr->csessions, cse, next); (void)csefree(cse); } - free(fcr, M_XDATA); + free(fcr, M_XDATA, 0); fp->f_data = NULL; return 0; } @@ -671,7 +671,7 @@ cryptoioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) error = falloc(p, &f, &fd); fdpunlock(p->p_fd); if (error) { - free(fcr, M_XDATA); + free(fcr, M_XDATA, 0); return (error); } f->f_flag = FREAD | FWRITE; @@ -751,9 +751,9 @@ csefree(struct csession *cse) error = crypto_freesession(cse->sid); if (cse->key) - free(cse->key, M_XDATA); + free(cse->key, M_XDATA, 0); if (cse->mackey) - free(cse->mackey, M_XDATA); - free(cse, M_XDATA); + free(cse->mackey, M_XDATA, 0); + free(cse, M_XDATA, 0); return (error); } diff --git a/sys/crypto/cryptosoft.c b/sys/crypto/cryptosoft.c index da5b82be2cd..81b8f273a46 100644 --- a/sys/crypto/cryptosoft.c +++ b/sys/crypto/cryptosoft.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cryptosoft.c,v 1.69 2013/08/25 14:26:56 jsing Exp $ */ +/* $OpenBSD: cryptosoft.c,v 1.70 2014/07/12 18:50:00 tedu Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) @@ -683,7 +683,7 @@ swcr_compdec(struct cryptodesc *crd, struct swcr_data *sw, else result = cxf->decompress(data, crd->crd_len, &out); - free(data, M_CRYPTO_DATA); + free(data, M_CRYPTO_DATA, 0); if (result == 0) return EINVAL; @@ -695,7 +695,7 @@ swcr_compdec(struct cryptodesc *crd, struct swcr_data *sw, if (crd->crd_flags & CRD_F_COMP) { if (result > crd->crd_len) { /* Compression was useless, we lost time */ - free(out, M_CRYPTO_DATA); + free(out, M_CRYPTO_DATA, 0); return 0; } } @@ -726,7 +726,7 @@ swcr_compdec(struct cryptodesc *crd, struct swcr_data *sw, } } } - free(out, M_CRYPTO_DATA); + free(out, M_CRYPTO_DATA, 0); return 0; } @@ -774,7 +774,7 @@ swcr_newsession(u_int32_t *sid, struct cryptoini *cri) if (swcr_sessions) { bcopy(swcr_sessions, swd, (swcr_sesnum / 2) * sizeof(struct swcr_data *)); - free(swcr_sessions, M_CRYPTO_DATA); + free(swcr_sessions, M_CRYPTO_DATA, 0); } swcr_sessions = swd; @@ -1023,7 +1023,7 @@ swcr_freesession(u_int64_t tid) if (swd->sw_kschedule) { explicit_bzero(swd->sw_kschedule, txf->ctxsize); - free(swd->sw_kschedule, M_CRYPTO_DATA); + free(swd->sw_kschedule, M_CRYPTO_DATA, 0); } break; @@ -1037,11 +1037,11 @@ swcr_freesession(u_int64_t tid) if (swd->sw_ictx) { explicit_bzero(swd->sw_ictx, axf->ctxsize); - free(swd->sw_ictx, M_CRYPTO_DATA); + free(swd->sw_ictx, M_CRYPTO_DATA, 0); } if (swd->sw_octx) { explicit_bzero(swd->sw_octx, axf->ctxsize); - free(swd->sw_octx, M_CRYPTO_DATA); + free(swd->sw_octx, M_CRYPTO_DATA, 0); } break; @@ -1051,11 +1051,11 @@ swcr_freesession(u_int64_t tid) if (swd->sw_ictx) { explicit_bzero(swd->sw_ictx, axf->ctxsize); - free(swd->sw_ictx, M_CRYPTO_DATA); + free(swd->sw_ictx, M_CRYPTO_DATA, 0); } if (swd->sw_octx) { explicit_bzero(swd->sw_octx, swd->sw_klen); - free(swd->sw_octx, M_CRYPTO_DATA); + free(swd->sw_octx, M_CRYPTO_DATA, 0); } break; @@ -1068,12 +1068,12 @@ swcr_freesession(u_int64_t tid) if (swd->sw_ictx) { explicit_bzero(swd->sw_ictx, axf->ctxsize); - free(swd->sw_ictx, M_CRYPTO_DATA); + free(swd->sw_ictx, M_CRYPTO_DATA, 0); } break; } - free(swd, M_CRYPTO_DATA); + free(swd, M_CRYPTO_DATA, 0); } return 0; } diff --git a/sys/crypto/xform_ipcomp.c b/sys/crypto/xform_ipcomp.c index a02c91c0118..4c1948d8ce9 100644 --- a/sys/crypto/xform_ipcomp.c +++ b/sys/crypto/xform_ipcomp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xform_ipcomp.c,v 1.3 2014/02/18 09:43:34 markus Exp $ */ +/* $OpenBSD: xform_ipcomp.c,v 1.4 2014/07/12 18:50:00 tedu Exp $ */ /* * Copyright (c) 2001 Jean-Jacques Bernard-Gundol (jj@wabbitt.org) @@ -142,13 +142,13 @@ deflate_global(u_int8_t *data, u_int32_t size, int decomp, u_int8_t **out) if (count > buf[j].size) { bcopy(buf[j].out, *out, buf[j].size); *out += buf[j].size; - free(buf[j].out, M_CRYPTO_DATA); + free(buf[j].out, M_CRYPTO_DATA, 0); count -= buf[j].size; } else { /* it should be the last buffer */ bcopy(buf[j].out, *out, count); *out += count; - free(buf[j].out, M_CRYPTO_DATA); + free(buf[j].out, M_CRYPTO_DATA, 0); count = 0; } } @@ -158,7 +158,7 @@ deflate_global(u_int8_t *data, u_int32_t size, int decomp, u_int8_t **out) bad: *out = NULL; for (j = 0; buf[j].flag != 0; j++) - free(buf[j].out, M_CRYPTO_DATA); + free(buf[j].out, M_CRYPTO_DATA, 0); if (decomp) inflateEnd(&zbuf); else diff --git a/sys/isofs/cd9660/cd9660_lookup.c b/sys/isofs/cd9660/cd9660_lookup.c index 8beaa39f51d..94ff10933d8 100644 --- a/sys/isofs/cd9660/cd9660_lookup.c +++ b/sys/isofs/cd9660/cd9660_lookup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_lookup.c,v 1.20 2013/06/11 16:42:15 deraadt Exp $ */ +/* $OpenBSD: cd9660_lookup.c,v 1.21 2014/07/12 18:50:00 tedu Exp $ */ /* $NetBSD: cd9660_lookup.c,v 1.18 1997/05/08 16:19:59 mycroft Exp $ */ /*- @@ -287,10 +287,10 @@ searchloop: cd9660_rrip_getname(ep,altname,&namelen,&dp->i_ino,imp); if (namelen == cnp->cn_namelen && !bcmp(name,altname,namelen)) { - free(altname, M_TEMP); + free(altname, M_TEMP, 0); goto found; } - free(altname, M_TEMP); + free(altname, M_TEMP, 0); ino = 0; break; } diff --git a/sys/isofs/cd9660/cd9660_node.c b/sys/isofs/cd9660/cd9660_node.c index b473466afcc..183b6bcc720 100644 --- a/sys/isofs/cd9660/cd9660_node.c +++ b/sys/isofs/cd9660/cd9660_node.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_node.c,v 1.23 2013/06/02 01:07:39 deraadt Exp $ */ +/* $OpenBSD: cd9660_node.c,v 1.24 2014/07/12 18:50:00 tedu Exp $ */ /* $NetBSD: cd9660_node.c,v 1.17 1997/05/05 07:13:57 mycroft Exp $ */ /*- @@ -217,7 +217,7 @@ cd9660_reclaim(v) vrele(ip->i_devvp); ip->i_devvp = 0; } - free(vp->v_data, M_ISOFSNODE); + free(vp->v_data, M_ISOFSNODE, 0); vp->v_data = NULL; return (0); } diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c index 959a77ac47b..a9bdc9a27ea 100644 --- a/sys/isofs/cd9660/cd9660_vfsops.c +++ b/sys/isofs/cd9660/cd9660_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_vfsops.c,v 1.67 2014/05/09 03:54:28 tedu Exp $ */ +/* $OpenBSD: cd9660_vfsops.c,v 1.68 2014/07/12 18:50:00 tedu Exp $ */ /* $NetBSD: cd9660_vfsops.c,v 1.26 1997/06/13 15:38:58 pk Exp $ */ /*- @@ -109,7 +109,7 @@ cd9660_mountroot() if ((error = iso_mountfs(rootvp, mp, p, &args)) != 0) { mp->mnt_vfc->vfc_refcount--; vfs_unbusy(mp); - free(mp, M_MOUNT); + free(mp, M_MOUNT, 0); return (error); } @@ -456,7 +456,7 @@ out: VOP_UNLOCK(devvp, 0, p); if (isomp) { - free((caddr_t)isomp, M_ISOFSMNT); + free((caddr_t)isomp, M_ISOFSMNT, 0); mp->mnt_data = (qaddr_t)0; } return (error); @@ -588,7 +588,7 @@ cd9660_unmount(mp, mntflags, p) vn_lock(isomp->im_devvp, LK_EXCLUSIVE | LK_RETRY, p); error = VOP_CLOSE(isomp->im_devvp, FREAD, NOCRED, p); vput(isomp->im_devvp); - free((caddr_t)isomp, M_ISOFSMNT); + free((caddr_t)isomp, M_ISOFSMNT, 0); mp->mnt_data = (qaddr_t)0; mp->mnt_flag &= ~MNT_LOCAL; return (error); diff --git a/sys/isofs/cd9660/cd9660_vnops.c b/sys/isofs/cd9660/cd9660_vnops.c index f092f047f91..0198d763e11 100644 --- a/sys/isofs/cd9660/cd9660_vnops.c +++ b/sys/isofs/cd9660/cd9660_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660_vnops.c,v 1.65 2014/05/09 03:54:28 tedu Exp $ */ +/* $OpenBSD: cd9660_vnops.c,v 1.66 2014/07/12 18:50:00 tedu Exp $ */ /* $NetBSD: cd9660_vnops.c,v 1.42 1997/10/16 23:56:57 christos Exp $ */ /*- @@ -198,7 +198,7 @@ cd9660_getattr(void *v) rdlnk.a_cred = ap->a_cred; if (cd9660_readlink(&rdlnk) == 0) vap->va_size = MAXPATHLEN - auio.uio_resid; - free(cp, M_TEMP); + free(cp, M_TEMP, 0); } vap->va_flags = 0; vap->va_gen = 1; @@ -262,7 +262,7 @@ cd9660_read(void *v) } error = breadn(vp, lbn, size, ra->blks, ra->sizes, i, &bp); - free(ra, M_TEMP); + free(ra, M_TEMP, 0); } else error = bread(vp, lbn, size, &bp); ci->ci_lastr = lbn; @@ -449,7 +449,7 @@ cd9660_readdir(void *v) if ((entryoffsetinblock = idp->curroff & bmask) && (error = cd9660_bufatoff(dp, (off_t)idp->curroff, NULL, &bp))) { - free(idp, M_TEMP); + free(idp, M_TEMP, 0); return (error); } endsearch = dp->i_size; @@ -562,7 +562,7 @@ cd9660_readdir(void *v) uio->uio_offset = idp->uio_off; *ap->a_eofflag = idp->eofflag; - free(idp, M_TEMP); + free(idp, M_TEMP, 0); return (error); } diff --git a/sys/isofs/udf/udf_vfsops.c b/sys/isofs/udf/udf_vfsops.c index 68842c81a63..e12553b9d97 100644 --- a/sys/isofs/udf/udf_vfsops.c +++ b/sys/isofs/udf/udf_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udf_vfsops.c,v 1.41 2013/05/30 17:35:01 guenther Exp $ */ +/* $OpenBSD: udf_vfsops.c,v 1.42 2014/07/12 18:50:00 tedu Exp $ */ /* * Copyright (c) 2001, 2002 Scott Long @@ -438,10 +438,10 @@ udf_mountfs(struct vnode *devvp, struct mount *mp, uint32_t lb, struct proc *p) bail: if (ump->um_hashtbl != NULL) - free(ump->um_hashtbl, M_UDFMOUNT); + free(ump->um_hashtbl, M_UDFMOUNT, 0); if (ump != NULL) { - free(ump, M_UDFMOUNT); + free(ump, M_UDFMOUNT, 0); mp->mnt_data = NULL; mp->mnt_flag &= ~MNT_LOCAL; } @@ -482,15 +482,15 @@ udf_unmount(struct mount *mp, int mntflags, struct proc *p) vrele(devvp); if (ump->um_flags & UDF_MNT_USES_VAT) - free(ump->um_vat, M_UDFMOUNT); + free(ump->um_vat, M_UDFMOUNT, 0); if (ump->um_stbl != NULL) - free(ump->um_stbl, M_UDFMOUNT); + free(ump->um_stbl, M_UDFMOUNT, 0); if (ump->um_hashtbl != NULL) - free(ump->um_hashtbl, M_UDFMOUNT); + free(ump->um_hashtbl, M_UDFMOUNT, 0); - free(ump, M_UDFMOUNT); + free(ump, M_UDFMOUNT, 0); mp->mnt_data = (qaddr_t)0; mp->mnt_flag &= ~MNT_LOCAL; @@ -634,7 +634,7 @@ udf_vget(struct mount *mp, ino_t ino, struct vnode **vpp) bp = NULL; if ((error = udf_allocv(mp, &vp, p))) { - free(up->u_fentry, M_UDFFENTRY); + free(up->u_fentry, M_UDFFENTRY, 0); pool_put(&unode_pool, up); return (error); /* Error from udf_allocv() */ } @@ -792,7 +792,7 @@ udf_get_spartmap(struct umount *ump, struct part_map_spare *pms) if (error) { if (bp != NULL) brelse(bp); - free(ump->um_stbl, M_UDFMOUNT); + free(ump->um_stbl, M_UDFMOUNT, 0); return (error); /* Failed to read sparing table */ } @@ -801,7 +801,7 @@ udf_get_spartmap(struct umount *ump, struct part_map_spare *pms) bp = NULL; if (udf_checktag(&ump->um_stbl->tag, 0)) { - free(ump->um_stbl, M_UDFMOUNT); + free(ump->um_stbl, M_UDFMOUNT, 0); return (EINVAL); /* Invalid sparing table found */ } diff --git a/sys/isofs/udf/udf_vnops.c b/sys/isofs/udf/udf_vnops.c index 454f21db8e0..4a4a45c2e17 100644 --- a/sys/isofs/udf/udf_vnops.c +++ b/sys/isofs/udf/udf_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udf_vnops.c,v 1.54 2013/12/14 02:57:25 guenther Exp $ */ +/* $OpenBSD: udf_vnops.c,v 1.55 2014/07/12 18:50:00 tedu Exp $ */ /* * Copyright (c) 2001, 2002 Scott Long @@ -598,7 +598,7 @@ udf_getfid(struct udf_dirstream *ds) */ if (ds->fid_fragment && ds->buf != NULL) { ds->fid_fragment = 0; - free(ds->buf, M_UDFFID); + free(ds->buf, M_UDFFID, 0); } fid = (struct fileid_desc*)&ds->data[ds->off]; @@ -699,7 +699,7 @@ udf_closedir(struct udf_dirstream *ds) } if (ds->fid_fragment && ds->buf != NULL) - free(ds->buf, M_UDFFID); + free(ds->buf, M_UDFFID, 0); pool_put(&udf_ds_pool, ds); } @@ -1172,7 +1172,7 @@ udf_reclaim(void *v) } if (up->u_fentry != NULL) - free(up->u_fentry, M_UDFFENTRY); + free(up->u_fentry, M_UDFFENTRY, 0); pool_put(&unode_pool, up); vp->v_data = NULL;