summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_intr.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-03-02 05:33:03 +0000
committerjhb <jhb@FreeBSD.org>2001-03-02 05:33:03 +0000
commit4376aa7f2b6b8e7211453f9f3832c71489e71f86 (patch)
tree25403e973e406a12e9abaec332fe657627d4998b /sys/kern/kern_intr.c
parente8e0f2c4fb182f870f4f69b2c7f2523a947f0bca (diff)
downloadFreeBSD-src-4376aa7f2b6b8e7211453f9f3832c71489e71f86.zip
FreeBSD-src-4376aa7f2b6b8e7211453f9f3832c71489e71f86.tar.gz
- Check to see if malloc() returned NULL even with M_WAITOK.
- Add a KASSERT() to ensure an ithread has a backing kernel thread when we schedule it. - Don't attempt to preemptively switch to an ithread if p_stat of curproc is not SRUN.
Diffstat (limited to 'sys/kern/kern_intr.c')
-rw-r--r--sys/kern/kern_intr.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c
index f64e89d..17bda0d 100644
--- a/sys/kern/kern_intr.c
+++ b/sys/kern/kern_intr.c
@@ -173,6 +173,8 @@ ithread_create(struct ithd **ithread, int vector, int flags,
return (EINVAL);
ithd = malloc(sizeof(struct ithd), M_ITHREAD, M_WAITOK | M_ZERO);
+ if (ithd == NULL)
+ return (ENOMEM);
ithd->it_vector = vector;
ithd->it_disable = disable;
ithd->it_enable = enable;
@@ -232,6 +234,8 @@ ithread_add_handler(struct ithd* ithread, const char *name,
flags |= INTR_EXCL;
ih = malloc(sizeof(struct intrhand), M_ITHREAD, M_WAITOK | M_ZERO);
+ if (ih == NULL)
+ return (ENOMEM);
ih->ih_handler = handler;
ih->ih_argument = arg;
ih->ih_name = name;
@@ -353,6 +357,7 @@ ithread_schedule(struct ithd *ithread, int do_switch)
}
p = ithread->it_proc;
+ KASSERT(p != NULL, ("ithread %s has no process", ithread->it_name));
CTR3(KTR_INTR, __func__ ": pid %d: (%s) need = %d", p->p_pid, p->p_comm,
ithread->it_need);
@@ -370,7 +375,7 @@ ithread_schedule(struct ithd *ithread, int do_switch)
CTR1(KTR_INTR, __func__ ": setrunqueue %d", p->p_pid);
p->p_stat = SRUN;
setrunqueue(p);
- if (do_switch) {
+ if (do_switch && curproc->p_stat == SRUN) {
saveintr = sched_lock.mtx_saveintr;
mtx_intr_enable(&sched_lock);
if (curproc != PCPU_GET(idleproc))
OpenPOWER on IntegriCloud