From cd982b5207bedb326e25ab56cd0030918cedb6c2 Mon Sep 17 00:00:00 2001 From: maxim Date: Thu, 15 Jun 2006 08:53:09 +0000 Subject: [PATCH] o Expand an exclusive lock scope to prevent a race between two simultaneous module_register(). Original work done by: Alex Lyashkov Reviewed by: jhb MFC after: 2 weeks --- sys/kern/kern_module.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_module.c b/sys/kern/kern_module.c index f92d39cb2814..97317172218e 100644 --- a/sys/kern/kern_module.c +++ b/sys/kern/kern_module.c @@ -136,20 +136,20 @@ module_register(const moduledata_t *data, linker_file_t container) size_t namelen; module_t newmod; - MOD_SLOCK; + MOD_XLOCK; newmod = module_lookupbyname(data->name); if (newmod != NULL) { - MOD_SUNLOCK; + MOD_XUNLOCK; printf("module_register: module %s already exists!\n", data->name); return (EEXIST); } - MOD_SUNLOCK; namelen = strlen(data->name) + 1; newmod = malloc(sizeof(struct module) + namelen, M_MODULE, M_WAITOK); - if (newmod == NULL) + if (newmod == NULL) { + MOD_XUNLOCK; return (ENOMEM); - MOD_XLOCK; + } newmod->refs = 1; newmod->id = nextid++; newmod->name = (char *)(newmod + 1);