Module Name: src Committed By: hannken Date: Wed Feb 6 09:29:46 UTC 2013
Modified Files: src/sys/dev: fss.c Log Message: Take fss_device_lock first when closing a fss device. Fixes PR kern/47514 (Multiple dump -X triggers kernel panic in fss_ioctl) To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/sys/dev/fss.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.83 src/sys/dev/fss.c:1.84 --- src/sys/dev/fss.c:1.83 Sat Jul 28 16:14:17 2012 +++ src/sys/dev/fss.c Wed Feb 6 09:29:46 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.83 2012/07/28 16:14:17 hannken Exp $ */ +/* $NetBSD: fss.c,v 1.84 2013/02/06 09:29:46 hannken Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.83 2012/07/28 16:14:17 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.84 2013/02/06 09:29:46 hannken Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -223,11 +223,13 @@ fss_close(dev_t dev, int flags, int mode mflag = (mode == S_IFCHR ? FSS_CDEV_OPEN : FSS_BDEV_OPEN); error = 0; + mutex_enter(&fss_device_lock); restart: mutex_enter(&sc->sc_slock); if ((sc->sc_flags & (FSS_CDEV_OPEN|FSS_BDEV_OPEN)) != mflag) { sc->sc_flags &= ~mflag; mutex_exit(&sc->sc_slock); + mutex_exit(&fss_device_lock); return 0; } if ((sc->sc_flags & FSS_ACTIVE) != 0 && @@ -239,12 +241,9 @@ restart: } if ((sc->sc_flags & FSS_ACTIVE) != 0) { mutex_exit(&sc->sc_slock); + mutex_exit(&fss_device_lock); return error; } - if (! mutex_tryenter(&fss_device_lock)) { - mutex_exit(&sc->sc_slock); - goto restart; - } KASSERT((sc->sc_flags & FSS_ACTIVE) == 0); KASSERT((sc->sc_flags & (FSS_CDEV_OPEN|FSS_BDEV_OPEN)) == mflag);