Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-2-0]: src/sys/net Pull up revision 1.23 (requested by dyoung in t...



details:   https://anonhg.NetBSD.org/src/rev/c498e7b1a437
branches:  netbsd-2-0
changeset: 564653:c498e7b1a437
user:      jdc <jdc%NetBSD.org@localhost>
date:      Fri Jan 07 15:26:53 2005 +0000

description:
Pull up revision 1.23 (requested by dyoung in ticket #1030).

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.

diffstat:

 sys/net/if_media.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (45 lines):

diff -r 36f494a16e1b -r c498e7b1a437 sys/net/if_media.c
--- a/sys/net/if_media.c        Fri Jan 07 15:02:26 2005 +0000
+++ b/sys/net/if_media.c        Fri Jan 07 15:26:53 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_media.c,v 1.21 2004/02/19 11:58:30 ragge Exp $      */
+/*     $NetBSD: if_media.c,v 1.21.2.1 2005/01/07 15:26:53 jdc Exp $    */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.21 2004/02/19 11:58:30 ragge Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_media.c,v 1.21.2.1 2005/01/07 15:26:53 jdc Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -108,6 +108,8 @@
 static void ifmedia_printword __P((int));
 #endif
 
+MALLOC_DEFINE(M_IFMEDIA, "ifmedia", "interface media state");
+
 /*
  * Initialize if_media struct for a specific interface instance.
  */
@@ -151,7 +153,7 @@
        }
 #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");
 
@@ -414,7 +416,7 @@
                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);
                }
        }
 }



Home | Main Index | Thread Index | Old Index