From fbfda7f8ad4bf2a83d91280caedf38fdd000667a Mon Sep 17 00:00:00 2001 From: deraadt Date: Sun, 9 Apr 2017 15:47:18 +0000 Subject: [PATCH] Correct wakeup() dance in sensor_task_work() Problem noticed by krw --- sys/kern/kern_sensors.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_sensors.c b/sys/kern/kern_sensors.c index 7cbe4019388..48c0fb096f0 100644 --- a/sys/kern/kern_sensors.c +++ b/sys/kern/kern_sensors.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sensors.c,v 1.37 2017/04/08 04:06:01 deraadt Exp $ */ +/* $OpenBSD: kern_sensors.c,v 1.38 2017/04/09 15:47:18 deraadt Exp $ */ /* * Copyright (c) 2005 David Gwynne @@ -263,8 +263,10 @@ sensor_task_work(void *xst) if (period > 0 && !sensors_quiesced) st->func(st->arg); rw_exit_write(&st->lock); - if (sensors_quiesced && atomic_dec_int_nv(&sensors_running) == 0) - wakeup(&sensors_running); + if (atomic_dec_int_nv(&sensors_running) == 0) { + if (sensors_quiesced) + wakeup(&sensors_running); + } if (period == 0) free(st, M_DEVBUF, sizeof(*st)); -- 2.20.1