diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2019-06-15 17:05:22 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2019-06-15 17:05:22 +0000 |
commit | e57cec2faf8555aae6bef4fbe4bad363a52a80ad (patch) | |
tree | 14ab336e1ec1c7e3e69698cfdb96e9793b5295bd /sys/net/if.c | |
parent | 9f68ecbf05ee7e98994b6fb8b66b05d40b2c0517 (diff) |
Free sizes for hooks and `if_sadl'.
ok kn@
Diffstat (limited to 'sys/net/if.c')
-rw-r--r-- | sys/net/if.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 31b107c8b4c..a5b992f4328 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.584 2019/06/04 23:06:34 sashan Exp $ */ +/* $OpenBSD: if.c,v 1.585 2019/06/15 17:05:21 mpi Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -469,8 +469,7 @@ if_alloc_sadl(struct ifnet *ifp) * now. This is useful for interfaces that can change * link types, and thus switch link names often. */ - if (ifp->if_sadl != NULL) - if_free_sadl(ifp); + if_free_sadl(ifp); namelen = strlen(ifp->if_xname); masklen = offsetof(struct sockaddr_dl, sdl_data[0]) + namelen; @@ -498,7 +497,10 @@ if_alloc_sadl(struct ifnet *ifp) void if_free_sadl(struct ifnet *ifp) { - free(ifp->if_sadl, M_IFADDR, 0); + if (ifp->if_sadl == NULL) + return; + + free(ifp->if_sadl, M_IFADDR, ifp->if_sadl->sdl_len); ifp->if_sadl = NULL; } @@ -1134,9 +1136,9 @@ if_detach(struct ifnet *ifp) } } - free(ifp->if_addrhooks, M_TEMP, 0); - free(ifp->if_linkstatehooks, M_TEMP, 0); - free(ifp->if_detachhooks, M_TEMP, 0); + free(ifp->if_addrhooks, M_TEMP, sizeof(*ifp->if_addrhooks)); + free(ifp->if_linkstatehooks, M_TEMP, sizeof(*ifp->if_linkstatehooks)); + free(ifp->if_detachhooks, M_TEMP, sizeof(*ifp->if_detachhooks)); for (i = 0; (dp = domains[i]) != NULL; i++) { if (dp->dom_ifdetach && ifp->if_afdata[dp->dom_family]) |