From cedb9875429363b208ae285e317318b542d7544b Mon Sep 17 00:00:00 2001 From: jhb Date: Tue, 27 Feb 2007 17:16:52 +0000 Subject: Always protect the kthread flags with the lock and close a race with module unload and kthread_exit(). MFC after: 3 days --- sys/dev/fdc/fdc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sys/dev/fdc') diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c index 7970232..22e810b 100644 --- a/sys/dev/fdc/fdc.c +++ b/sys/dev/fdc/fdc.c @@ -1205,7 +1205,6 @@ fdc_thread(void *arg) mtx_lock(&fdc->fdc_mtx); } fdc->flags &= ~(FDC_KTHREAD_EXIT | FDC_KTHREAD_ALIVE); - wakeup(&fdc->fdc_thread); mtx_unlock(&fdc->fdc_mtx); kthread_exit(0); @@ -1711,8 +1710,8 @@ fdc_detach(device_t dev) return (error); /* kill worker thread */ - fdc->flags |= FDC_KTHREAD_EXIT; mtx_lock(&fdc->fdc_mtx); + fdc->flags |= FDC_KTHREAD_EXIT; wakeup(&fdc->head); while ((fdc->flags & FDC_KTHREAD_ALIVE) != 0) msleep(&fdc->fdc_thread, &fdc->fdc_mtx, PRIBIO, "fdcdet", 0); -- cgit v1.1