Avoid a lock order reversal by dropping the eventhandler_mutex earlier.

We get enough protection from the lock on the individual lists that we
aquire later.

Noticed/Tested by: Steven G. Kargl <kargl@troutmask.apl.washington.edu>
Submitted by: Jonathan Mini <mini@haikugeek.com>
This commit is contained in:
Alfred Perlstein 2002-04-04 00:52:03 +00:00
parent 51b5a2f445
commit 19a0f7e1be

View File

@ -101,11 +101,11 @@ eventhandler_register(struct eventhandler_list *list, char *name,
sx_init(&list->el_lock, name);
list->el_flags = EHE_INITTED;
}
mtx_unlock(&eventhandler_mutex);
/* allocate an entry for this handler, populate it */
if ((eg = malloc(sizeof(struct eventhandler_entry_generic),
M_EVENTHANDLER, M_NOWAIT)) == NULL) {
mtx_unlock(&eventhandler_mutex);
return(NULL);
}
eg->func = func;
@ -125,7 +125,6 @@ eventhandler_register(struct eventhandler_list *list, char *name,
if (ep == NULL)
TAILQ_INSERT_TAIL(&list->el_entries, &eg->ee, ee_link);
EHE_UNLOCK(list);
mtx_unlock(&eventhandler_mutex);
return(&eg->ee);
}