From a8699ab9a44f6d8566ff6588378b1fd464d57880 Mon Sep 17 00:00:00 2001 From: dyoung Date: Wed, 8 Dec 2004 20:37:43 +0000 Subject: [PATCH] As pointed out by Greg Troxel, ifmedia_entrys were allocated with malloc_type M_IFADDR and freed with malloc_type M_DEVBUF. This causes a panic(9) in DIAGNOSTIC kernels. Add malloc_type M_IFMEDIA and use it for both malloc'ing and free'ing ifmedia_entrys. --- sys/net/if_media.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/net/if_media.c b/sys/net/if_media.c index 55111d0b9c29..9a0622fb9832 100644 --- a/sys/net/if_media.c +++ b/sys/net/if_media.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_media.c,v 1.22 2004/04/09 20:44:57 thorpej Exp $ */ +/* $NetBSD: if_media.c,v 1.23 2004/12/08 20:37:43 dyoung Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -83,7 +83,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.22 2004/04/09 20:44:57 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.23 2004/12/08 20:37:43 dyoung Exp $"); #include #include @@ -108,6 +108,8 @@ int ifmedia_debug = 0; static void ifmedia_printword(int); #endif +MALLOC_DEFINE(M_IFMEDIA, "ifmedia", "interface media state"); + /* * Initialize if_media struct for a specific interface instance. */ @@ -144,7 +146,7 @@ ifmedia_add(struct ifmedia *ifm, int mword, int data, void *aux) } #endif - entry = malloc(sizeof(*entry), M_IFADDR, M_NOWAIT); + entry = malloc(sizeof(*entry), M_IFMEDIA, M_NOWAIT); if (entry == NULL) panic("ifmedia_add: can't malloc entry"); @@ -394,7 +396,7 @@ ifmedia_delete_instance(struct ifmedia *ifm, u_int inst) if (inst == IFM_INST_ANY || inst == IFM_INST(ife->ifm_media)) { TAILQ_REMOVE(&ifm->ifm_list, ife, ifm_list); - free(ife, M_DEVBUF); + free(ife, M_IFMEDIA); } } }