diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2007-10-03 10:52:12 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2007-10-03 10:52:12 +0000 |
commit | 91e049d131acb98a8b3ff54ab8f882b27b354479 (patch) | |
tree | 2ccb5b9450d014d6731c31bc458bcc57a8a15916 | |
parent | a2f23a0f4539991c8472613441751eead15267e9 (diff) |
MALLOC+bzero -> malloc+M_ZERO.
In ip_esp.c all allocated memory is now zero'd in the
"malloc(sizeof(*tc) + alen ..." case. The +alen memory was not
initialized by the bzero() call. Noticed by chl@.
"Looks good" art@ "seems ok" chl@
-rw-r--r-- | sys/arch/mvme68k/dev/vs.c | 5 | ||||
-rw-r--r-- | sys/arch/mvme88k/dev/vs.c | 5 | ||||
-rw-r--r-- | sys/arch/zaurus/dev/zaurus_flash.c | 6 | ||||
-rw-r--r-- | sys/dev/ic/if_wi_hostap.c | 7 | ||||
-rw-r--r-- | sys/isofs/cd9660/cd9660_vfsops.c | 6 | ||||
-rw-r--r-- | sys/isofs/udf/udf_vfsops.c | 6 | ||||
-rw-r--r-- | sys/msdosfs/msdosfs_denode.c | 6 | ||||
-rw-r--r-- | sys/netatalk/ddp_usrreq.c | 5 | ||||
-rw-r--r-- | sys/netinet/ip_esp.c | 13 | ||||
-rw-r--r-- | sys/netinet/ip_ipcomp.c | 10 | ||||
-rw-r--r-- | sys/netnatm/natm_pcb.c | 5 | ||||
-rw-r--r-- | sys/ntfs/ntfs_subr.c | 13 |
12 files changed, 29 insertions, 58 deletions
diff --git a/sys/arch/mvme68k/dev/vs.c b/sys/arch/mvme68k/dev/vs.c index 88bb063b231..e61f6050f74 100644 --- a/sys/arch/mvme68k/dev/vs.c +++ b/sys/arch/mvme68k/dev/vs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vs.c,v 1.20 2006/06/02 18:53:56 miod Exp $ */ +/* $OpenBSD: vs.c,v 1.21 2007/10/03 10:52:11 krw Exp $ */ /* * Copyright (c) 1999 Steve Murphree, Jr. @@ -822,8 +822,7 @@ vs_alloc_scatter_gather() { M328_SG sg; - MALLOC(sg, M328_SG, sizeof(struct m328_sg), M_DEVBUF, M_WAITOK); - bzero(sg, sizeof(struct m328_sg)); + sg = malloc(sizeof(struct m328_sg), M_DEVBUF, M_WAITOK | M_ZERO); return (sg); } diff --git a/sys/arch/mvme88k/dev/vs.c b/sys/arch/mvme88k/dev/vs.c index 55ad50a0305..16b32a16720 100644 --- a/sys/arch/mvme88k/dev/vs.c +++ b/sys/arch/mvme88k/dev/vs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vs.c,v 1.64 2006/12/01 19:36:09 miod Exp $ */ +/* $OpenBSD: vs.c,v 1.65 2007/10/03 10:52:11 krw Exp $ */ /* * Copyright (c) 2004, Miodrag Vallat. @@ -958,8 +958,7 @@ vs_alloc_scatter_gather(void) { M328_SG sg; - MALLOC(sg, M328_SG, sizeof(struct m328_sg), M_DEVBUF, M_WAITOK); - bzero(sg, sizeof(struct m328_sg)); + sg = malloc(sizeof(struct m328_sg), M_DEVBUF, M_WAITOK | M_ZERO); return (sg); } diff --git a/sys/arch/zaurus/dev/zaurus_flash.c b/sys/arch/zaurus/dev/zaurus_flash.c index 5f2af195799..0568ad4b720 100644 --- a/sys/arch/zaurus/dev/zaurus_flash.c +++ b/sys/arch/zaurus/dev/zaurus_flash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zaurus_flash.c,v 1.4 2007/06/20 18:15:46 deraadt Exp $ */ +/* $OpenBSD: zaurus_flash.c,v 1.5 2007/10/03 10:52:11 krw Exp $ */ /* * Copyright (c) 2005 Uwe Stuehler <uwe@openbsd.org> @@ -622,12 +622,10 @@ zflash_safe_start(struct zflash_softc *sc, dev_t dev) if (DL_GETPOFFSET(&lp->d_partitions[part]) % blksect) return EIO; - MALLOC(sp, struct zflash_safe *, sizeof(struct zflash_safe), - M_DEVBUF, M_NOWAIT); + sp = malloc(sizeof(*sp), M_DEVBUF, M_NOWAIT | M_ZERO); if (sp == NULL) return ENOMEM; - bzero(sp, sizeof(struct zflash_safe)); sp->sp_dev = dev; sp->sp_pblks = DL_GETPSIZE(&lp->d_partitions[part]) / blksect; diff --git a/sys/dev/ic/if_wi_hostap.c b/sys/dev/ic/if_wi_hostap.c index 79aea6b94be..29e6412bafd 100644 --- a/sys/dev/ic/if_wi_hostap.c +++ b/sys/dev/ic/if_wi_hostap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wi_hostap.c,v 1.37 2006/11/26 19:46:28 deraadt Exp $ */ +/* $OpenBSD: if_wi_hostap.c,v 1.38 2007/10/03 10:52:11 krw Exp $ */ /* * Copyright (c) 2002 @@ -461,13 +461,10 @@ wihap_sta_alloc(struct wi_softc *sc, u_int8_t *addr) int i, hash = sta_hash_func(addr); /* Allocate structure. */ - MALLOC(sta, struct wihap_sta_info *, sizeof(struct wihap_sta_info), - M_DEVBUF, M_NOWAIT); + sta = malloc(sizeof(*sta), M_DEVBUF, M_NOWAIT | M_ZERO); if (sta == NULL) return (NULL); - bzero(sta, sizeof(struct wihap_sta_info)); - /* Allocate an ASID. */ i=hash<<4; while (whi->asid_inuse_mask[i >> 4] & (1UL << (i & 0xf))) diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c index 0b1d075aba6..7a162c87f6e 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.46 2007/06/08 05:35:32 deraadt Exp $ */ +/* $OpenBSD: cd9660_vfsops.c,v 1.47 2007/10/03 10:52:11 krw Exp $ */ /* $NetBSD: cd9660_vfsops.c,v 1.26 1997/06/13 15:38:58 pk Exp $ */ /*- @@ -765,9 +765,7 @@ retry: *vpp = NULLVP; return (error); } - MALLOC(ip, struct iso_node *, sizeof(struct iso_node), M_ISOFSNODE, - M_WAITOK); - bzero((caddr_t)ip, sizeof(struct iso_node)); + ip = malloc(sizeof(*ip), M_ISOFSNODE, M_WAITOK | M_ZERO); lockinit(&ip->i_lock, PINOD, "isoinode", 0, 0); vp->v_data = ip; ip->i_vnode = vp; diff --git a/sys/isofs/udf/udf_vfsops.c b/sys/isofs/udf/udf_vfsops.c index fe665d99bb4..3159d53f55b 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.23 2006/08/07 15:50:42 pedro Exp $ */ +/* $OpenBSD: udf_vfsops.c,v 1.24 2007/10/03 10:52:11 krw Exp $ */ /* * Copyright (c) 2001, 2002 Scott Long <scottl@freebsd.org> @@ -248,9 +248,7 @@ udf_mountfs(struct vnode *devvp, struct mount *mp, uint32_t lb, struct proc *p) if (error) return (error); - MALLOC(ump, struct umount *, sizeof(struct umount), M_UDFMOUNT, - M_WAITOK); - bzero(ump, sizeof(struct umount)); + ump = malloc(sizeof(*ump), M_UDFMOUNT, M_WAITOK | M_ZERO); mp->mnt_data = (qaddr_t) ump; mp->mnt_stat.f_fsid.val[0] = devvp->v_rdev; diff --git a/sys/msdosfs/msdosfs_denode.c b/sys/msdosfs/msdosfs_denode.c index 8e7ff21add4..9b663546c82 100644 --- a/sys/msdosfs/msdosfs_denode.c +++ b/sys/msdosfs/msdosfs_denode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_denode.c,v 1.32 2007/06/02 02:04:21 deraadt Exp $ */ +/* $OpenBSD: msdosfs_denode.c,v 1.33 2007/10/03 10:52:11 krw Exp $ */ /* $NetBSD: msdosfs_denode.c,v 1.23 1997/10/17 11:23:58 ws Exp $ */ /*- @@ -226,9 +226,7 @@ retry: *depp = 0; return (error); } - MALLOC(ldep, struct denode *, sizeof(struct denode), M_MSDOSFSNODE, - M_WAITOK); - bzero((caddr_t)ldep, sizeof *ldep); + ldep = malloc(sizeof(*ldep), M_MSDOSFSNODE, M_WAITOK | M_ZERO); lockinit(&ldep->de_lock, PINOD, "denode", 0, 0); nvp->v_data = ldep; ldep->de_vnode = nvp; diff --git a/sys/netatalk/ddp_usrreq.c b/sys/netatalk/ddp_usrreq.c index 039666adffc..284e03e9df4 100644 --- a/sys/netatalk/ddp_usrreq.c +++ b/sys/netatalk/ddp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ddp_usrreq.c,v 1.8 2007/05/26 12:09:40 claudio Exp $ */ +/* $OpenBSD: ddp_usrreq.c,v 1.9 2007/10/03 10:52:11 krw Exp $ */ /* * Copyright (c) 1990,1994 Regents of The University of Michigan. @@ -469,11 +469,10 @@ at_pcballoc( so ) { struct ddpcb *ddp; - MALLOC( ddp, struct ddpcb *, sizeof( *ddp ), M_PCB, M_NOWAIT ); + ddp = malloc(sizeof(*ddp), M_PCB, M_NOWAIT | M_ZERO); if ( ddp == NULL ) { return (ENOBUFS); } - bzero( ddp, sizeof( *ddp )); ddp->ddp_lsat.sat_port = ATADDR_ANYPORT; diff --git a/sys/netinet/ip_esp.c b/sys/netinet/ip_esp.c index a348c53960f..cfd1148b1d5 100644 --- a/sys/netinet/ip_esp.c +++ b/sys/netinet/ip_esp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_esp.c,v 1.100 2006/12/15 09:32:30 otto Exp $ */ +/* $OpenBSD: ip_esp.c,v 1.101 2007/10/03 10:52:11 krw Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -408,11 +408,9 @@ esp_input(struct mbuf *m, struct tdb *tdb, int skip, int protoff) /* Get IPsec-specific opaque pointer */ if (esph == NULL || mtag != NULL) - MALLOC(tc, struct tdb_crypto *, sizeof(struct tdb_crypto), - M_XDATA, M_NOWAIT); + tc = malloc(sizeof(*tc), M_XDATA, M_NOWAIT | M_ZERO); else - MALLOC(tc, struct tdb_crypto *, - sizeof(struct tdb_crypto) + alen, M_XDATA, M_NOWAIT); + tc = malloc(sizeof(*tc) + alen, M_XDATA, M_NOWAIT | M_ZERO); if (tc == NULL) { m_freem(m); crypto_freereq(crp); @@ -421,7 +419,6 @@ esp_input(struct mbuf *m, struct tdb *tdb, int skip, int protoff) return ENOBUFS; } - bzero(tc, sizeof(struct tdb_crypto)); tc->tc_ptr = (caddr_t) mtag; if (esph) { @@ -961,8 +958,7 @@ esp_output(struct mbuf *m, struct tdb *tdb, struct mbuf **mp, int skip, crda = crp->crp_desc; /* IPsec-specific opaque crypto info. */ - MALLOC(tc, struct tdb_crypto *, sizeof(struct tdb_crypto), - M_XDATA, M_NOWAIT); + tc = malloc(sizeof(*tc), M_XDATA, M_NOWAIT | M_ZERO); if (tc == NULL) { m_freem(m); crypto_freereq(crp); @@ -971,7 +967,6 @@ esp_output(struct mbuf *m, struct tdb *tdb, struct mbuf **mp, int skip, return ENOBUFS; } - bzero(tc, sizeof(struct tdb_crypto)); tc->tc_spi = tdb->tdb_spi; tc->tc_proto = tdb->tdb_sproto; bcopy(&tdb->tdb_dst, &tc->tc_dst, sizeof(union sockaddr_union)); diff --git a/sys/netinet/ip_ipcomp.c b/sys/netinet/ip_ipcomp.c index 3e07cb66eae..8f23dc0a906 100644 --- a/sys/netinet/ip_ipcomp.c +++ b/sys/netinet/ip_ipcomp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipcomp.c,v 1.20 2006/03/25 22:41:48 djm Exp $ */ +/* $OpenBSD: ip_ipcomp.c,v 1.21 2007/10/03 10:52:11 krw Exp $ */ /* * Copyright (c) 2001 Jean-Jacques Bernard-Gundol (jj@wabbitt.org) @@ -163,8 +163,7 @@ ipcomp_input(m, tdb, skip, protoff) return ENOBUFS; } /* Get IPsec-specific opaque pointer */ - MALLOC(tc, struct tdb_crypto *, sizeof(struct tdb_crypto), - M_XDATA, M_NOWAIT); + tc = malloc(sizeof(*tc), M_XDATA, M_NOWAIT | M_ZERO); if (tc == NULL) { m_freem(m); crypto_freereq(crp); @@ -172,7 +171,6 @@ ipcomp_input(m, tdb, skip, protoff) ipcompstat.ipcomps_crypto++; return ENOBUFS; } - bzero(tc, sizeof(struct tdb_crypto)); crdc = crp->crp_desc; crdc->crd_skip = skip + hlen; @@ -515,8 +513,7 @@ ipcomp_output(m, tdb, mp, skip, protoff) crdc->crd_alg = ipcompx->type; /* IPsec-specific opaque crypto info */ - MALLOC(tc, struct tdb_crypto *, sizeof(struct tdb_crypto), - M_XDATA, M_NOWAIT); + tc = malloc(sizeof(*tc), M_XDATA, M_NOWAIT | M_ZERO); if (tc == NULL) { m_freem(m); crypto_freereq(crp); @@ -524,7 +521,6 @@ ipcomp_output(m, tdb, mp, skip, protoff) ipcompstat.ipcomps_crypto++; return ENOBUFS; } - bzero(tc, sizeof(struct tdb_crypto)); tc->tc_spi = tdb->tdb_spi; tc->tc_proto = tdb->tdb_sproto; diff --git a/sys/netnatm/natm_pcb.c b/sys/netnatm/natm_pcb.c index 45d7c391266..e5f14669551 100644 --- a/sys/netnatm/natm_pcb.c +++ b/sys/netnatm/natm_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: natm_pcb.c,v 1.7 2006/03/05 21:48:57 miod Exp $ */ +/* $OpenBSD: natm_pcb.c,v 1.8 2007/10/03 10:52:11 krw Exp $ */ /* * @@ -65,10 +65,9 @@ int wait; { struct natmpcb *npcb; - MALLOC(npcb, struct natmpcb *, sizeof(*npcb), M_PCB, wait); + npcb = malloc(sizeof(*npcb), M_PCB, wait | M_ZERO); if (npcb) { - bzero(npcb, sizeof(*npcb)); npcb->npcb_flags = NPCB_FREE; } return(npcb); diff --git a/sys/ntfs/ntfs_subr.c b/sys/ntfs/ntfs_subr.c index 24891e564a1..bd2a5b8682d 100644 --- a/sys/ntfs/ntfs_subr.c +++ b/sys/ntfs/ntfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntfs_subr.c,v 1.11 2007/06/02 01:02:56 deraadt Exp $ */ +/* $OpenBSD: ntfs_subr.c,v 1.12 2007/10/03 10:52:11 krw Exp $ */ /* $NetBSD: ntfs_subr.c,v 1.4 2003/04/10 21:37:32 jdolecek Exp $ */ /*- @@ -435,10 +435,8 @@ ntfs_ntlookup( } } while (lockmgr(&ntfs_hashlock, LK_EXCLUSIVE | LK_SLEEPFAIL, NULL)); - MALLOC(ip, struct ntnode *, sizeof(struct ntnode), - M_NTFSNTNODE, M_WAITOK); + ip = malloc(sizeof(*ip), M_NTFSNTNODE, M_WAITOK | M_ZERO); ddprintf(("ntfs_ntlookup: allocating ntnode: %d: %p\n", ino, ip)); - bzero((caddr_t) ip, sizeof(struct ntnode)); /* Generic initialization */ ip->i_devvp = ntmp->ntm_devvp; @@ -584,9 +582,7 @@ ntfs_attrtontvattr( error = 0; *rvapp = NULL; - MALLOC(vap, struct ntvattr *, sizeof(struct ntvattr), - M_NTFSNTVATTR, M_WAITOK); - bzero(vap, sizeof(struct ntvattr)); + vap = malloc(sizeof(*vap), M_NTFSNTVATTR, M_WAITOK | M_ZERO); vap->va_ip = NULL; vap->va_flag = rap->a_hdr.a_flag; vap->va_type = rap->a_hdr.a_type; @@ -794,8 +790,7 @@ ntfs_fget( if (*fpp) return (0); - MALLOC(fp, struct fnode *, sizeof(struct fnode), M_NTFSFNODE, M_WAITOK); - bzero(fp, sizeof(struct fnode)); + fp = malloc(sizeof(*fp), M_NTFSFNODE, M_WAITOK | M_ZERO); dprintf(("ntfs_fget: allocating fnode: %p\n",fp)); fp->f_ip = ip; |