From: mpi Date: Mon, 22 Aug 2016 10:33:22 +0000 (+0000) Subject: Sizes for free(9) from David Hill. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=62cf959d4fe4f8c38c164b34477ceebb3785dcb6;p=openbsd Sizes for free(9) from David Hill. --- diff --git a/sys/netinet6/frag6.c b/sys/netinet6/frag6.c index a15f95533b1..9f281150e5e 100644 --- a/sys/netinet6/frag6.c +++ b/sys/netinet6/frag6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: frag6.c,v 1.67 2016/03/07 18:44:00 naddy Exp $ */ +/* $OpenBSD: frag6.c,v 1.68 2016/08/22 10:33:22 mpi Exp $ */ /* $KAME: frag6.c,v 1.40 2002/05/27 21:40:31 itojun Exp $ */ /* @@ -303,7 +303,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto) /* dequeue the fragment. */ LIST_REMOVE(af6, ip6af_list); - free(af6, M_FTABLE, 0); + free(af6, M_FTABLE, sizeof(*af6)); /* adjust pointer. */ ip6err = mtod(merr, struct ip6_hdr *); @@ -348,14 +348,14 @@ frag6_input(struct mbuf **mp, int *offp, int proto) ecn0 = (ntohl(af6->ip6af_flow) >> 20) & IPTOS_ECN_MASK; if (ecn == IPTOS_ECN_CE) { if (ecn0 == IPTOS_ECN_NOTECT) { - free(ip6af, M_FTABLE, 0); + free(ip6af, M_FTABLE, sizeof(*ip6af)); goto dropfrag; } if (ecn0 != IPTOS_ECN_CE) af6->ip6af_flow |= htonl(IPTOS_ECN_CE << 20); } if (ecn == IPTOS_ECN_NOTECT && ecn0 != IPTOS_ECN_NOTECT) { - free(ip6af, M_FTABLE, 0); + free(ip6af, M_FTABLE, sizeof(*ip6af)); goto dropfrag; } @@ -384,7 +384,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto) i, inet_ntop(AF_INET6, &q6->ip6q_src, ip, sizeof(ip))); #endif - free(ip6af, M_FTABLE, 0); + free(ip6af, M_FTABLE, sizeof(*ip6af)); goto flushfrags; } } @@ -398,7 +398,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto) i, inet_ntop(AF_INET6, &q6->ip6q_src, ip, sizeof(ip))); #endif - free(ip6af, M_FTABLE, 0); + free(ip6af, M_FTABLE, sizeof(*ip6af)); goto flushfrags; } } @@ -449,12 +449,12 @@ frag6_input(struct mbuf **mp, int *offp, int proto) t = t->m_next; t->m_next = IP6_REASS_MBUF(af6); m_adj(t->m_next, af6->ip6af_offset); - free(af6, M_FTABLE, 0); + free(af6, M_FTABLE, sizeof(*af6)); } /* adjust offset to point where the original next header starts */ offset = ip6af->ip6af_offset - sizeof(struct ip6_frag); - free(ip6af, M_FTABLE, 0); + free(ip6af, M_FTABLE, sizeof(*ip6af)); ip6 = mtod(m, struct ip6_hdr *); ip6->ip6_plen = htons((u_short)next + offset - sizeof(struct ip6_hdr)); ip6->ip6_src = q6->ip6q_src; @@ -465,7 +465,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto) if (frag6_deletefraghdr(m, offset) != 0) { TAILQ_REMOVE(&frag6_queue, q6, ip6q_queue); frag6_nfrags -= q6->ip6q_nfrag; - free(q6, M_FTABLE, 0); + free(q6, M_FTABLE, sizeof(*q6)); frag6_nfragpackets--; goto dropfrag; } @@ -480,7 +480,7 @@ frag6_input(struct mbuf **mp, int *offp, int proto) TAILQ_REMOVE(&frag6_queue, q6, ip6q_queue); frag6_nfrags -= q6->ip6q_nfrag; - free(q6, M_FTABLE, 0); + free(q6, M_FTABLE, sizeof(*q6)); frag6_nfragpackets--; if (m->m_flags & M_PKTHDR) { /* Isn't it always true? */ @@ -506,12 +506,12 @@ frag6_input(struct mbuf **mp, int *offp, int proto) while ((af6 = LIST_FIRST(&q6->ip6q_asfrag)) != NULL) { LIST_REMOVE(af6, ip6af_list); m_freem(IP6_REASS_MBUF(af6)); - free(af6, M_FTABLE, 0); + free(af6, M_FTABLE, sizeof(*af6)); } ip6stat.ip6s_fragdropped += q6->ip6q_nfrag; TAILQ_REMOVE(&frag6_queue, q6, ip6q_queue); frag6_nfrags -= q6->ip6q_nfrag; - free(q6, M_FTABLE, 0); + free(q6, M_FTABLE, sizeof(*q6)); frag6_nfragpackets--; dropfrag: @@ -579,11 +579,11 @@ frag6_freef(struct ip6q *q6) ICMP6_TIME_EXCEED_REASSEMBLY, 0); } else m_freem(m); - free(af6, M_FTABLE, 0); + free(af6, M_FTABLE, sizeof(*af6)); } TAILQ_REMOVE(&frag6_queue, q6, ip6q_queue); frag6_nfrags -= q6->ip6q_nfrag; - free(q6, M_FTABLE, 0); + free(q6, M_FTABLE, sizeof(*q6)); frag6_nfragpackets--; } diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 219c6c9491b..8ecdd65cc0a 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.c,v 1.190 2016/08/08 13:09:36 mpi Exp $ */ +/* $OpenBSD: in6.c,v 1.191 2016/08/22 10:33:22 mpi Exp $ */ /* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */ /* @@ -1917,5 +1917,5 @@ in6_domifdetach(struct ifnet *ifp, void *aux) struct in6_ifextra *ext = (struct in6_ifextra *)aux; nd6_ifdetach(ext->nd_ifinfo); - free(ext, M_IFADDR, 0); + free(ext, M_IFADDR, sizeof(*ext)); } diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 05931bd5897..e5c4de720ca 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_output.c,v 1.211 2016/07/01 18:18:57 jca Exp $ */ +/* $OpenBSD: ip6_output.c,v 1.212 2016/08/22 10:33:22 mpi Exp $ */ /* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */ /* @@ -1754,7 +1754,7 @@ ip6_pcbopts(struct ip6_pktopts **pktopt, struct mbuf *m, struct socket *so) * Only turning off any previous options, regardless of * whether the opt is just created or given. */ - free(opt, M_IP6OPT, 0); + free(opt, M_IP6OPT, sizeof(*opt)); return (0); } @@ -1764,7 +1764,7 @@ ip6_pcbopts(struct ip6_pktopts **pktopt, struct mbuf *m, struct socket *so) if ((error = ip6_setpktopts(m, opt, NULL, priv, so->so_proto->pr_protocol)) != 0) { ip6_clearpktopts(opt, -1); /* XXX discard all options */ - free(opt, M_IP6OPT, 0); + free(opt, M_IP6OPT, sizeof(*opt)); return (error); } *pktopt = opt; diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index b523d4a08c8..66676cc879b 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.c,v 1.188 2016/07/13 08:40:46 mpi Exp $ */ +/* $OpenBSD: nd6.c,v 1.189 2016/08/22 10:33:22 mpi Exp $ */ /* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */ /* @@ -153,7 +153,7 @@ void nd6_ifdetach(struct nd_ifinfo *nd) { - free(nd, M_IP6NDP, 0); + free(nd, M_IP6NDP, sizeof(*nd)); } void @@ -1634,7 +1634,7 @@ nd6_sysctl(int name, void *oldp, size_t *oldlenp, void *newp, size_t newlen) ol = oldlenp ? *oldlenp : 0; if (oldp) { - p = malloc(*oldlenp, M_TEMP, M_WAITOK | M_CANFAIL); + p = malloc(ol, M_TEMP, M_WAITOK | M_CANFAIL); if (!p) return ENOMEM; } else @@ -1656,8 +1656,7 @@ nd6_sysctl(int name, void *oldp, size_t *oldlenp, void *newp, size_t newlen) error = ENOPROTOOPT; break; } - if (p) - free(p, M_TEMP, 0); + free(p, M_TEMP, ol); return (error); } diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c index 6e2b6b32dde..f845628139d 100644 --- a/sys/netinet6/nd6_nbr.c +++ b/sys/netinet6/nd6_nbr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6_nbr.c,v 1.108 2016/08/04 20:46:24 vgross Exp $ */ +/* $OpenBSD: nd6_nbr.c,v 1.109 2016/08/22 10:33:22 mpi Exp $ */ /* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */ /* @@ -1207,7 +1207,7 @@ nd6_dad_stop(struct ifaddr *ifa) nd6_dad_stoptimer(dp); TAILQ_REMOVE(&dadq, (struct dadq *)dp, dad_list); - free(dp, M_IP6NDP, 0); + free(dp, M_IP6NDP, sizeof(*dp)); dp = NULL; ifafree(ifa); ip6_dad_pending--; @@ -1256,7 +1256,7 @@ nd6_dad_timer(struct ifaddr *ifa) ifa->ifa_ifp->if_xname)); TAILQ_REMOVE(&dadq, (struct dadq *)dp, dad_list); - free(dp, M_IP6NDP, 0); + free(dp, M_IP6NDP, sizeof(*dp)); dp = NULL; ifafree(ifa); ip6_dad_pending--; @@ -1306,7 +1306,7 @@ nd6_dad_timer(struct ifaddr *ifa) addr, sizeof(addr)))); TAILQ_REMOVE(&dadq, (struct dadq *)dp, dad_list); - free(dp, M_IP6NDP, 0); + free(dp, M_IP6NDP, sizeof(*dp)); dp = NULL; ifafree(ifa); ip6_dad_pending--; @@ -1343,7 +1343,7 @@ nd6_dad_duplicated(struct dadq *dp) TAILQ_REMOVE(&dadq, dp, dad_list); ifafree(dp->dad_ifa); - free(dp, M_IP6NDP, 0); + free(dp, M_IP6NDP, sizeof(*dp)); ip6_dad_pending--; } diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index e5ffc328e6b..6fdac5a708f 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6_rtr.c,v 1.140 2016/07/05 10:17:14 mpi Exp $ */ +/* $OpenBSD: nd6_rtr.c,v 1.141 2016/08/22 10:33:22 mpi Exp $ */ /* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */ /* @@ -667,7 +667,7 @@ defrtrlist_del(struct nd_defrouter *dr) dr->ifp->if_xname); } - free(dr, M_IP6NDP, 0); + free(dr, M_IP6NDP, sizeof(*dr)); } /* @@ -995,7 +995,7 @@ void pfxrtr_del(struct nd_pfxrouter *pfr) { LIST_REMOVE(pfr, pfr_entry); - free(pfr, M_IP6NDP, 0); + free(pfr, M_IP6NDP, sizeof(*pfr)); } struct nd_prefix * @@ -1145,7 +1145,7 @@ prelist_remove(struct nd_prefix *pr) /* free list of routers that adversed the prefix */ LIST_FOREACH_SAFE(pfr, &pr->ndpr_advrtrs, pfr_entry, next) - free(pfr, M_IP6NDP, 0); + free(pfr, M_IP6NDP, sizeof(*pfr)); ext->nprefixes--; if (ext->nprefixes < 0) { @@ -1153,7 +1153,7 @@ prelist_remove(struct nd_prefix *pr) pr->ndpr_ifp->if_xname); } - free(pr, M_IP6NDP, 0); + free(pr, M_IP6NDP, sizeof(*pr)); pfxlist_onlink_check(); splx(s); diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index 2cdcfa59082..0cbf2306804 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip6.c,v 1.94 2016/08/04 20:46:24 vgross Exp $ */ +/* $OpenBSD: raw_ip6.c,v 1.95 2016/08/22 10:33:22 mpi Exp $ */ /* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */ /* @@ -631,10 +631,9 @@ rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, if (so == ip6_mrouter) ip6_mrouter_done(); #endif - if (in6p->inp_icmp6filt) { - free(in6p->inp_icmp6filt, M_PCB, 0); - in6p->inp_icmp6filt = NULL; - } + free(in6p->inp_icmp6filt, M_PCB, sizeof(struct icmp6_filter)); + in6p->inp_icmp6filt = NULL; + in_pcbdetach(in6p); break;