Module Name: src Committed By: msaitoh Date: Sun Jun 9 11:29:43 UTC 2013
Modified Files: src/sys/dev [netbsd-5]: fss.c Log Message: Pull up following revision(s) (requested by gdt in ticket #1853): sys/dev/fss.c: revision 1.84 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.60.4.6 -r1.60.4.7 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.60.4.6 src/sys/dev/fss.c:1.60.4.7 --- src/sys/dev/fss.c:1.60.4.6 Thu Aug 23 08:59:47 2012 +++ src/sys/dev/fss.c Sun Jun 9 11:29:43 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.60.4.6 2012/08/23 08:59:47 bouyer Exp $ */ +/* $NetBSD: fss.c,v 1.60.4.7 2013/06/09 11:29:43 msaitoh Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.60.4.6 2012/08/23 08:59:47 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.60.4.7 2013/06/09 11:29:43 msaitoh Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -221,11 +221,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 && @@ -237,12 +239,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);