diff options
| author | bad <bad@NetBSD.org> | 2013-11-17 17:01:44 +0000 |
|---|---|---|
| committer | bad <bad@NetBSD.org> | 2013-11-17 17:01:44 +0000 |
| commit | 644ee6fda37bb726d9ee6db4d537064f56c23e7d (patch) | |
| tree | 7180ff5e00bb288dffef8c72b2b0e297bf8cc212 /sys/dev | |
| parent | f60cad8d89a05f9dcd11a76979492a8fdaaab7d2 (diff) | |
Fix locking botch. Callers of ubsec_rng_locked() lock and release sc_mtx already.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/pci/ubsec.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/sys/dev/pci/ubsec.c b/sys/dev/pci/ubsec.c index d19f860ad1a..f858c54924e 100644 --- a/sys/dev/pci/ubsec.c +++ b/sys/dev/pci/ubsec.c @@ -1,4 +1,4 @@ -/* $NetBSD: ubsec.c,v 1.30 2013/11/17 16:54:02 bad Exp $ */ +/* $NetBSD: ubsec.c,v 1.31 2013/11/17 17:01:44 bad Exp $ */ /* $FreeBSD: src/sys/dev/ubsec/ubsec.c,v 1.6.2.6 2003/01/23 21:06:43 sam Exp $ */ /* $OpenBSD: ubsec.c,v 1.127 2003/06/04 14:04:58 jason Exp $ */ @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.30 2013/11/17 16:54:02 bad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.31 2013/11/17 17:01:44 bad Exp $"); #undef UBSEC_DEBUG @@ -1774,15 +1774,15 @@ ubsec_rng_locked(void *vsc) struct ubsec_mcr *mcr; struct ubsec_ctx_rngbypass *ctx; - mutex_spin_enter(&sc->sc_mtx); + /* Caller is responsible to lock and release sc_mtx. */ + KASSERT(mutex_owned(&sc->sc_mtx)); + if (rng->rng_used) { - mutex_spin_exit(&sc->sc_mtx); return; } if (sc->sc_rng_need < 1) { callout_stop(&sc->sc_rngto); - mutex_spin_exit(&sc->sc_mtx); return; } @@ -1815,7 +1815,6 @@ ubsec_rng_locked(void *vsc) rng->rng_used = 1; ubsec_feed2(sc); ubsecstats.hst_rng++; - mutex_spin_exit(&sc->sc_mtx); return; @@ -1824,7 +1823,6 @@ out: * Something weird happened, generate our own call back. */ sc->sc_nqueue2--; - mutex_spin_exit(&sc->sc_mtx); #ifdef __OpenBSD__ timeout_add(&sc->sc_rngto, sc->sc_rnghz); #else |
