diff options
author | 2014-12-09 07:16:41 +0000 | |
---|---|---|
committer | 2014-12-09 07:16:41 +0000 | |
commit | 540e394a3c7d66751d7b0a37fd250502b8f42deb (patch) | |
tree | 3f737e8fb0ebef86efddc986ebab3ac0e9ce5c23 | |
parent | More malloc() -> mallocarray() in the kernel. (diff) | |
download | wireguard-openbsd-540e394a3c7d66751d7b0a37fd250502b8f42deb.tar.xz wireguard-openbsd-540e394a3c7d66751d7b0a37fd250502b8f42deb.zip |
Sprinkle in a little more mallocarray().
ok deraadt@ tedu@
-rw-r--r-- | sys/ntfs/ntfs_subr.c | 6 | ||||
-rw-r--r-- | sys/ntfs/ntfs_vfsops.c | 4 | ||||
-rw-r--r-- | sys/uvm/uvm_amap.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_aobj.c | 10 | ||||
-rw-r--r-- | sys/uvm/uvm_mmap.c | 4 |
5 files changed, 15 insertions, 15 deletions
diff --git a/sys/ntfs/ntfs_subr.c b/sys/ntfs/ntfs_subr.c index 91192ee0124..aa2984dbbb3 100644 --- a/sys/ntfs/ntfs_subr.c +++ b/sys/ntfs/ntfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntfs_subr.c,v 1.39 2014/09/14 14:17:26 jsg Exp $ */ +/* $OpenBSD: ntfs_subr.c,v 1.40 2014/12/09 07:16:41 doug Exp $ */ /* $NetBSD: ntfs_subr.c,v 1.4 2003/04/10 21:37:32 jdolecek Exp $ */ /*- @@ -611,8 +611,8 @@ ntfs_runtovrun(cn_t **rcnp, cn_t **rclp, u_long *rcntp, u_int8_t *run) off += (run[off] & 0xF) + ((run[off] >> 4) & 0xF) + 1; cnt++; } - cn = malloc(cnt * sizeof(cn_t), M_NTFSRUN, M_WAITOK); - cl = malloc(cnt * sizeof(cn_t), M_NTFSRUN, M_WAITOK); + cn = mallocarray(cnt, sizeof(cn_t), M_NTFSRUN, M_WAITOK); + cl = mallocarray(cnt, sizeof(cn_t), M_NTFSRUN, M_WAITOK); off = 0; cnt = 0; diff --git a/sys/ntfs/ntfs_vfsops.c b/sys/ntfs/ntfs_vfsops.c index 099d0c0d381..9d24d635351 100644 --- a/sys/ntfs/ntfs_vfsops.c +++ b/sys/ntfs/ntfs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntfs_vfsops.c,v 1.41 2014/11/18 23:55:01 krw Exp $ */ +/* $OpenBSD: ntfs_vfsops.c,v 1.42 2014/12/09 07:16:41 doug Exp $ */ /* $NetBSD: ntfs_vfsops.c,v 1.7 2003/04/24 07:50:19 christos Exp $ */ /*- @@ -411,7 +411,7 @@ ntfs_mountfs(struct vnode *devvp, struct mount *mp, struct ntfs_args *argsp, } /* Alloc memory for attribute definitions */ - ntmp->ntm_ad = malloc(num * sizeof(struct ntvattrdef), + ntmp->ntm_ad = mallocarray(num, sizeof(struct ntvattrdef), M_NTFSMNT, M_WAITOK); ntmp->ntm_adnum = num; diff --git a/sys/uvm/uvm_amap.c b/sys/uvm/uvm_amap.c index 1c258b40c65..6acc23a3c53 100644 --- a/sys/uvm/uvm_amap.c +++ b/sys/uvm/uvm_amap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_amap.c,v 1.55 2014/11/16 12:31:00 deraadt Exp $ */ +/* $OpenBSD: uvm_amap.c,v 1.56 2014/12/09 07:16:41 doug Exp $ */ /* $NetBSD: uvm_amap.c,v 1.27 2000/11/25 06:27:59 chs Exp $ */ /* @@ -328,7 +328,7 @@ amap_extend(struct vm_map_entry *entry, vsize_t addsize) #ifdef UVM_AMAP_PPREF newppref = NULL; if (amap->am_ppref && amap->am_ppref != PPREF_NONE) { - newppref = malloc(slotalloc *sizeof(int), M_UVMAMAP, + newppref = mallocarray(slotalloc, sizeof(int), M_UVMAMAP, M_WAITOK | M_CANFAIL); if (newppref == NULL) { /* give up if malloc fails */ @@ -744,7 +744,7 @@ void amap_pp_establish(struct vm_amap *amap) { - amap->am_ppref = malloc(sizeof(int) * amap->am_maxslot, + amap->am_ppref = mallocarray(amap->am_maxslot, sizeof(int), M_UVMAMAP, M_NOWAIT|M_ZERO); /* if we fail then we just won't use ppref for this amap */ diff --git a/sys/uvm/uvm_aobj.c b/sys/uvm/uvm_aobj.c index 043d1651088..7ac8883f0bb 100644 --- a/sys/uvm/uvm_aobj.c +++ b/sys/uvm/uvm_aobj.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_aobj.c,v 1.72 2014/11/21 07:18:44 tedu Exp $ */ +/* $OpenBSD: uvm_aobj.c,v 1.73 2014/12/09 07:16:41 doug Exp $ */ /* $NetBSD: uvm_aobj.c,v 1.39 2001/02/18 21:19:08 chs Exp $ */ /* @@ -485,7 +485,7 @@ uao_shrink_convert(struct uvm_object *uobj, int pages) struct uao_swhash_elt *elt; int i, *new_swslots; - new_swslots = malloc(pages * sizeof(int), M_UVMAOBJ, + new_swslots = mallocarray(pages, sizeof(int), M_UVMAOBJ, M_WAITOK | M_CANFAIL | M_ZERO); if (new_swslots == NULL) return ENOMEM; @@ -520,7 +520,7 @@ uao_shrink_array(struct uvm_object *uobj, int pages) struct uvm_aobj *aobj = (struct uvm_aobj *)uobj; int i, *new_swslots; - new_swslots = malloc(pages * sizeof(int), M_UVMAOBJ, + new_swslots = mallocarray(pages, sizeof(int), M_UVMAOBJ, M_WAITOK | M_CANFAIL | M_ZERO); if (new_swslots == NULL) return ENOMEM; @@ -575,7 +575,7 @@ uao_grow_array(struct uvm_object *uobj, int pages) KASSERT(aobj->u_pages <= UAO_SWHASH_THRESHOLD); - new_swslots = malloc(pages * sizeof(int), M_UVMAOBJ, + new_swslots = mallocarray(pages, sizeof(int), M_UVMAOBJ, M_WAITOK | M_CANFAIL | M_ZERO); if (new_swslots == NULL) return ENOMEM; @@ -748,7 +748,7 @@ uao_create(vsize_t size, int flags) panic("uao_create: hashinit swhash failed"); } } else { - aobj->u_swslots = malloc(pages * sizeof(int), + aobj->u_swslots = mallocarray(pages, sizeof(int), M_UVMAOBJ, mflags|M_ZERO); if (aobj->u_swslots == NULL) { if (flags & UAO_FLAG_CANFAIL) { diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c index 3ed329127b7..10e92411f0b 100644 --- a/sys/uvm/uvm_mmap.c +++ b/sys/uvm/uvm_mmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_mmap.c,v 1.100 2014/11/16 12:31:00 deraadt Exp $ */ +/* $OpenBSD: uvm_mmap.c,v 1.101 2014/12/09 07:16:41 doug Exp $ */ /* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */ /* @@ -201,7 +201,7 @@ sys_mincore(struct proc *p, void *v, register_t *retval) */ if (npgs >= (0xffffffff >> PAGE_SHIFT)) return (E2BIG); - pgs = malloc(sizeof(*pgs) * npgs, M_TEMP, M_WAITOK | M_CANFAIL); + pgs = mallocarray(npgs, sizeof(*pgs), M_TEMP, M_WAITOK | M_CANFAIL); if (pgs == NULL) return (ENOMEM); pgi = pgs; |