pmf_event_deregister: fix use-after-free.

Found by: CID 4754.
This commit is contained in:
rmind 2007-12-23 22:09:39 +00:00
parent 940524edab
commit 099e4a9a20
1 changed files with 4 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_pmf.c,v 1.7 2007/12/21 23:49:55 jmcneill Exp $ */
/* $NetBSD: kern_pmf.c,v 1.8 2007/12/23 22:09:39 rmind Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.7 2007/12/21 23:49:55 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.8 2007/12/23 22:09:39 rmind Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -529,7 +529,8 @@ pmf_event_deregister(device_t dv, pmf_generic_event_t ev,
{
pmf_event_handler_t *event;
TAILQ_FOREACH(event, &pmf_all_events, pmf_link) {
while (!TAILQ_EMPTY(&pmf_all_events)) {
event = TAILQ_FIRST(&pmf_all_events);
if (event->pmf_event != ev)
continue;
if (event->pmf_device != dv)