diff options
author | 2019-06-10 16:32:51 +0000 | |
---|---|---|
committer | 2019-06-10 16:32:51 +0000 | |
commit | b82d192b5f65a9c7874e171ed8a92d692ac77073 (patch) | |
tree | 42cc6110bad462f674291150412b3fda035a1965 /sys/net/if_vxlan.c | |
parent | Use PWAIT instead of PUSER in tsleep(9). (diff) | |
download | wireguard-openbsd-b82d192b5f65a9c7874e171ed8a92d692ac77073.tar.xz wireguard-openbsd-b82d192b5f65a9c7874e171ed8a92d692ac77073.zip |
Use mallocarray(9) & put some free(9) sizes for M_IPMOPTS allocations.
ok semarie@, visa@
Diffstat (limited to 'sys/net/if_vxlan.c')
-rw-r--r-- | sys/net/if_vxlan.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c index ca42e7f8a21..328af93cce7 100644 --- a/sys/net/if_vxlan.c +++ b/sys/net/if_vxlan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vxlan.c,v 1.72 2019/04/28 22:15:58 mpi Exp $ */ +/* $OpenBSD: if_vxlan.c,v 1.73 2019/06/10 16:32:51 mpi Exp $ */ /* * Copyright (c) 2013 Reyk Floeter <reyk@openbsd.org> @@ -131,9 +131,8 @@ vxlan_clone_create(struct if_clone *ifc, int unit) struct vxlan_softc *sc; sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO); - sc->sc_imo.imo_membership = malloc( - (sizeof(struct in_multi *) * IP_MIN_MEMBERSHIPS), M_IPMOPTS, - M_WAITOK|M_ZERO); + sc->sc_imo.imo_membership = mallocarray(IP_MIN_MEMBERSHIPS, + sizeof(struct in_multi *), M_IPMOPTS, M_WAITOK|M_ZERO); sc->sc_imo.imo_max_memberships = IP_MIN_MEMBERSHIPS; sc->sc_dstport = htons(VXLAN_PORT); sc->sc_vnetid = VXLAN_VNI_UNSET; @@ -199,7 +198,8 @@ vxlan_clone_destroy(struct ifnet *ifp) if (!task_del(net_tq(ifp->if_index), &sc->sc_sendtask)) taskq_barrier(net_tq(ifp->if_index)); - free(sc->sc_imo.imo_membership, M_IPMOPTS, 0); + free(sc->sc_imo.imo_membership, M_IPMOPTS, + sc->sc_imo.imo_max_memberships * sizeof(struct in_multi *)); free(sc, M_DEVBUF, sizeof(*sc)); return (0); |