From 64747bca1d386fa7c8528f7a7fc1f4f9ddfd4b63 Mon Sep 17 00:00:00 2001 From: hannken Date: Tue, 13 Oct 2009 12:37:19 +0000 Subject: [PATCH] Fix a race where the backing store thread runs (and exits immediately) before kthread_create() returns. --- sys/dev/fss.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sys/dev/fss.c b/sys/dev/fss.c index c6f7f10b2c3f..11038a97895f 100644 --- a/sys/dev/fss.c +++ b/sys/dev/fss.c @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.63 2009/06/29 05:08:17 dholland Exp $ */ +/* $NetBSD: fss.c,v 1.64 2009/10/13 12:37:19 hannken Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.63 2009/06/29 05:08:17 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.64 2009/10/13 12:37:19 hannken Exp $"); #include #include @@ -446,11 +446,12 @@ fss_softc_alloc(struct fss_softc *sc) sc->sc_indir_data = NULL; } - if ((error = kthread_create(PRI_BIO, 0, NULL, fss_bs_thread, sc, - &sc->sc_bs_lwp, device_xname(sc->sc_dev))) != 0) - return error; - sc->sc_flags |= FSS_BS_THREAD; + if ((error = kthread_create(PRI_BIO, 0, NULL, fss_bs_thread, sc, + &sc->sc_bs_lwp, device_xname(sc->sc_dev))) != 0) { + sc->sc_flags &= ~FSS_BS_THREAD; + return error; + } disk_attach(sc->sc_dkdev);