From 7363f77230e80a0f7d86d52229cc5d1770e7e277 Mon Sep 17 00:00:00 2001 From: pooka Date: Wed, 3 Mar 2010 17:58:36 +0000 Subject: [PATCH] Replace unsafe use of TAILQ_FOREACH: as the comment says, the structures are pulled off the list in the loop and it's anyone's guess where they go after that. --- sys/kern/kern_module.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_module.c b/sys/kern/kern_module.c index 6176d2f62541..52983e2c05d8 100644 --- a/sys/kern/kern_module.c +++ b/sys/kern/kern_module.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_module.c,v 1.57 2010/01/19 15:23:14 pooka Exp $ */ +/* $NetBSD: kern_module.c,v 1.58 2010/03/03 17:58:36 pooka Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.57 2010/01/19 15:23:14 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.58 2010/03/03 17:58:36 pooka Exp $"); #define _MODULE_INTERNAL @@ -247,7 +247,7 @@ module_init_class(modclass_t class) { __link_set_decl(modules, modinfo_t); modinfo_t *const *mip, *mi; - module_t *mod; + module_t *mod, *mod_next; mutex_enter(&module_lock); /* @@ -268,7 +268,8 @@ module_init_class(modclass_t class) * list as we call module_do_load(); */ do { - TAILQ_FOREACH(mod, &module_bootlist, mod_chain) { + for (mod = TAILQ_FIRST(&module_bootlist); mod; mod = mod_next) { + mod_next = TAILQ_NEXT(mod, mod_chain); mi = mod->mod_info; if (class != MODULE_CLASS_ANY && class != mi->mi_class)