Use malloc/free instead of kmem_alloc/kmem_free in pmf_event_inject, since

the latter is not safe to use from a softint. Pointed out by rmind.
This commit is contained in:
jmcneill 2007-12-11 01:00:45 +00:00
parent f40133bd10
commit 5bd9c210ef
1 changed files with 6 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_pmf.c,v 1.3 2007/12/10 23:50:25 xtraeme Exp $ */ /* $NetBSD: kern_pmf.c,v 1.4 2007/12/11 01:00:45 jmcneill Exp $ */
/*- /*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca> * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
@ -33,7 +33,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.3 2007/12/10 23:50:25 xtraeme Exp $"); __KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.4 2007/12/11 01:00:45 jmcneill Exp $");
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
@ -44,7 +44,6 @@ __KERNEL_RCSID(0, "$NetBSD: kern_pmf.c,v 1.3 2007/12/10 23:50:25 xtraeme Exp $")
#include <sys/device.h> #include <sys/device.h>
#include <sys/pmf.h> #include <sys/pmf.h>
#include <sys/queue.h> #include <sys/queue.h>
#include <sys/kmem.h>
#include <sys/syscallargs.h> /* for sys_sync */ #include <sys/syscallargs.h> /* for sys_sync */
#include <sys/workqueue.h> #include <sys/workqueue.h>
#include <prop/proplib.h> #include <prop/proplib.h>
@ -106,7 +105,9 @@ pmf_event_worker(struct work *wk, void *dummy)
(*event->pmf_handler)(event->pmf_device); (*event->pmf_handler)(event->pmf_device);
} }
kmem_free(pew, sizeof(pmf_event_workitem_t)); free(pew, M_TEMP);
return;
} }
static bool static bool
@ -450,7 +451,7 @@ pmf_event_inject(device_t dv, pmf_generic_event_t ev)
{ {
pmf_event_workitem_t *pew; pmf_event_workitem_t *pew;
pew = kmem_alloc(sizeof(pmf_event_workitem_t), KM_NOSLEEP); pew = malloc(sizeof(pmf_event_workitem_t), M_TEMP, M_NOWAIT);
if (pew == NULL) { if (pew == NULL) {
PMF_EVENT_PRINTF(("%s: PMF event %d dropped (no memory)\n", PMF_EVENT_PRINTF(("%s: PMF event %d dropped (no memory)\n",
dv ? device_xname(dv) : "<anonymous>", ev)); dv ? device_xname(dv) : "<anonymous>", ev));