Close a very narrow race that might cause a trigger allocation to be

leaked if a trigger is delivered as the trigger device is closed.

Obtained from:	TrustedBSD Project
This commit is contained in:
Robert Watson 2007-06-13 21:17:23 +00:00
parent 6f93a78c1a
commit 6a9a600b49
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=170687

View File

@ -132,15 +132,14 @@ send_trigger(unsigned int trigger)
{
struct trigger_info *ti;
/* If nobody's listening, we ain't talking. */
if (!audit_isopen)
return (ENODEV);
/*
* Note: Use a condition variable instead of msleep/wakeup?
*/
ti = malloc(sizeof *ti, M_AUDITTRIGGER, M_WAITOK);
mtx_lock(&audit_trigger_mtx);
if (!audit_isopen) {
/* If nobody's listening, we ain't talking. */
mtx_unlock(&audit_trigger_mtx);
free(ti, M_AUDITTRIGGER);
return (ENODEV);
}
ti->trigger = trigger;
TAILQ_INSERT_TAIL(&trigger_list, ti, list);
wakeup(&trigger_list);