summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2014-11-20 15:55:04 +0000
committertedu <tedu@openbsd.org>2014-11-20 15:55:04 +0000
commit8df9ba4d34f8c4374a47035d73287cae555dbb2d (patch)
tree98050c3496d804e2a389543d14376ea1059d4a9d
parentremove sys/file.h includes in favor of fcntl.h where needed. (diff)
downloadwireguard-openbsd-8df9ba4d34f8c4374a47035d73287cae555dbb2d.tar.xz
wireguard-openbsd-8df9ba4d34f8c4374a47035d73287cae555dbb2d.zip
sizes for simple free cases. sizeof(*) and one case where len is clear.
-rw-r--r--sys/netinet/in.c6
-rw-r--r--sys/netinet/ip_carp.c20
-rw-r--r--sys/netinet/ip_output.c22
3 files changed, 24 insertions, 24 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index 531abfd3dd2..72cff241d76 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.c,v 1.109 2014/11/20 10:06:54 mpi Exp $ */
+/* $OpenBSD: in.c,v 1.110 2014/11/20 15:55:04 tedu Exp $ */
/* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */
/*
@@ -964,7 +964,7 @@ in_addmulti(struct in_addr *ap, struct ifnet *ifp)
*/
memcpy(&ifr.ifr_addr, &inm->inm_sin, sizeof(inm->inm_sin));
if ((*ifp->if_ioctl)(ifp, SIOCADDMULTI,(caddr_t)&ifr) != 0) {
- free(inm, M_IPMADDR, 0);
+ free(inm, M_IPMADDR, sizeof(*inm));
return (NULL);
}
@@ -1017,7 +1017,7 @@ in_delmulti(struct in_multi *inm)
splx(s);
}
- free(inm, M_IPMADDR, 0);
+ free(inm, M_IPMADDR, sizeof(*inm));
}
}
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index a030692c083..cf1ff611b3f 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_carp.c,v 1.238 2014/11/18 02:37:31 tedu Exp $ */
+/* $OpenBSD: ip_carp.c,v 1.239 2014/11/20 15:55:04 tedu Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@@ -726,7 +726,7 @@ carp_clone_create(ifc, unit)
LIST_INIT(&sc->carp_vhosts);
sc->sc_vhe_count = 0;
if (carp_new_vhost(sc, 0, 0)) {
- free(sc, M_DEVBUF, 0);
+ free(sc, M_DEVBUF, sizeof(*sc));
return (ENOMEM);
}
@@ -815,7 +815,7 @@ carp_clone_destroy(struct ifnet *ifp)
if_detach(ifp);
carp_destroy_vhosts(ifp->if_softc);
free(sc->sc_imo.imo_membership, M_IPMOPTS, 0);
- free(sc, M_DEVBUF, 0);
+ free(sc, M_DEVBUF, sizeof(*sc));
return (0);
}
@@ -862,7 +862,7 @@ carpdetach(struct carp_softc *sc)
if (!--cif->vhif_nvrs) {
ifpromisc(sc->sc_carpdev, 0);
sc->sc_carpdev->if_carp = NULL;
- free(cif, M_IFADDR, 0);
+ free(cif, M_IFADDR, sizeof(*cif));
}
}
sc->sc_carpdev = NULL;
@@ -890,7 +890,7 @@ carp_destroy_vhosts(struct carp_softc *sc)
for (vhe = LIST_FIRST(&sc->carp_vhosts); vhe != NULL; vhe = nvhe) {
nvhe = LIST_NEXT(vhe, vhost_entries);
- free(vhe, M_DEVBUF, 0);
+ free(vhe, M_DEVBUF, sizeof(*vhe));
}
LIST_INIT(&sc->carp_vhosts);
sc->sc_vhe_count = 0;
@@ -1682,7 +1682,7 @@ carp_set_ifp(struct carp_softc *sc, struct ifnet *ifp)
if (ncif == NULL)
return (ENOBUFS);
if ((error = ifpromisc(ifp, 1))) {
- free(ncif, M_IFADDR, 0);
+ free(ncif, M_IFADDR, sizeof(*ncif));
return (error);
}
@@ -2529,7 +2529,7 @@ carp_ether_addmulti(struct carp_softc *sc, struct ifreq *ifr)
* about it. Also, remember this multicast address so that
* we can delete them on unconfigure.
*/
- mc = malloc(sizeof(struct carp_mc_entry), M_DEVBUF, M_NOWAIT);
+ mc = malloc(sizeof(*mc), M_DEVBUF, M_NOWAIT);
if (mc == NULL) {
error = ENOMEM;
goto alloc_failed;
@@ -2552,7 +2552,7 @@ carp_ether_addmulti(struct carp_softc *sc, struct ifreq *ifr)
ioctl_failed:
LIST_REMOVE(mc, mc_entries);
- free(mc, M_DEVBUF, 0);
+ free(mc, M_DEVBUF, sizeof(*mc));
alloc_failed:
(void)ether_delmulti(ifr, (struct arpcom *)&sc->sc_ac);
@@ -2599,7 +2599,7 @@ carp_ether_delmulti(struct carp_softc *sc, struct ifreq *ifr)
if (error == 0) {
/* And forget about this address. */
LIST_REMOVE(mc, mc_entries);
- free(mc, M_DEVBUF, 0);
+ free(mc, M_DEVBUF, sizeof(*mc));
} else
(void)ether_addmulti(ifr, (struct arpcom *)&sc->sc_ac);
return (error);
@@ -2631,6 +2631,6 @@ carp_ether_purgemulti(struct carp_softc *sc)
memcpy(&ifr->ifr_addr, &mc->mc_addr, mc->mc_addr.ss_len);
(void)(*ifp->if_ioctl)(ifp, SIOCDELMULTI, (caddr_t)ifr);
LIST_REMOVE(mc, mc_entries);
- free(mc, M_DEVBUF, 0);
+ free(mc, M_DEVBUF, sizeof(*mc));
}
}
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index b224f7f122d..d05976cacc8 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_output.c,v 1.271 2014/11/05 14:03:02 mpi Exp $ */
+/* $OpenBSD: ip_output.c,v 1.272 2014/11/20 15:55:04 tedu Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@@ -945,6 +945,7 @@ ip_ctloutput(int op, struct socket *so, int level, int optname,
struct proc *p = curproc; /* XXX */
#ifdef IPSEC
struct ipsec_ref *ipr;
+ size_t iprlen;
u_int16_t opt16val;
#endif
int error = 0;
@@ -1221,8 +1222,8 @@ ip_ctloutput(int op, struct socket *so, int level, int optname,
}
}
- ipr = malloc(sizeof(struct ipsec_ref) + m->m_len - 2,
- M_CREDENTIALS, M_NOWAIT);
+ iprlen = sizeof(struct ipsec_ref) + m->m_len - 2;
+ ipr = malloc(iprlen, M_CREDENTIALS, M_NOWAIT);
if (ipr == NULL) {
error = ENOBUFS;
break;
@@ -1240,7 +1241,7 @@ ip_ctloutput(int op, struct socket *so, int level, int optname,
if (ipr->ref_type < IPSP_IDENTITY_PREFIX ||
ipr->ref_type > IPSP_IDENTITY_CONNECTION ||
((char *)(ipr + 1))[ipr->ref_len - 1]) {
- free(ipr, M_CREDENTIALS, 0);
+ free(ipr, M_CREDENTIALS, iprlen);
error = EINVAL;
} else {
if (inp->inp_ipo->ipo_srcid != NULL)
@@ -1253,7 +1254,7 @@ ip_ctloutput(int op, struct socket *so, int level, int optname,
if (ipr->ref_type < IPSP_IDENTITY_PREFIX ||
ipr->ref_type > IPSP_IDENTITY_CONNECTION ||
((char *)(ipr + 1))[ipr->ref_len - 1]) {
- free(ipr, M_CREDENTIALS, 0);
+ free(ipr, M_CREDENTIALS, iprlen);
error = EINVAL;
} else {
if (inp->inp_ipo->ipo_dstid != NULL)
@@ -1264,7 +1265,7 @@ ip_ctloutput(int op, struct socket *so, int level, int optname,
case IP_IPSEC_LOCAL_CRED:
if (ipr->ref_type < IPSP_CRED_KEYNOTE ||
ipr->ref_type > IPSP_CRED_X509) {
- free(ipr, M_CREDENTIALS, 0);
+ free(ipr, M_CREDENTIALS, iprlen);
error = EINVAL;
} else {
if (inp->inp_ipo->ipo_local_cred != NULL)
@@ -1275,7 +1276,7 @@ ip_ctloutput(int op, struct socket *so, int level, int optname,
case IP_IPSEC_LOCAL_AUTH:
if (ipr->ref_type < IPSP_AUTH_PASSPHRASE ||
ipr->ref_type > IPSP_AUTH_RSA) {
- free(ipr, M_CREDENTIALS, 0);
+ free(ipr, M_CREDENTIALS, iprlen);
error = EINVAL;
} else {
if (inp->inp_ipo->ipo_local_auth != NULL)
@@ -1672,8 +1673,7 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m,
* No multicast option buffer attached to the pcb;
* allocate one and initialize to default values.
*/
- imo = (struct ip_moptions *)malloc(sizeof(*imo), M_IPMOPTS,
- M_WAITOK|M_ZERO);
+ imo = malloc(sizeof(*imo), M_IPMOPTS, M_WAITOK|M_ZERO);
immp = (struct in_multi **)malloc(
(sizeof(*immp) * IP_MIN_MEMBERSHIPS), M_IPMOPTS,
M_WAITOK|M_ZERO);
@@ -1930,7 +1930,7 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m,
imo->imo_multicast_loop == IP_DEFAULT_MULTICAST_LOOP &&
imo->imo_num_memberships == 0) {
free(imo->imo_membership , M_IPMOPTS, 0);
- free(*imop, M_IPMOPTS, 0);
+ free(*imop, M_IPMOPTS, sizeof(**imop));
*imop = NULL;
}
@@ -1995,7 +1995,7 @@ ip_freemoptions(struct ip_moptions *imo)
for (i = 0; i < imo->imo_num_memberships; ++i)
in_delmulti(imo->imo_membership[i]);
free(imo->imo_membership, M_IPMOPTS, 0);
- free(imo, M_IPMOPTS, 0);
+ free(imo, M_IPMOPTS, sizeof(*imo));
}
}