Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb make sure we're holding the kernel lock when cal...



details:   https://anonhg.NetBSD.org/src/rev/c7d57f21a2ce
branches:  trunk
changeset: 773683:c7d57f21a2ce
user:      mrg <mrg%NetBSD.org@localhost>
date:      Mon Feb 13 01:51:02 2012 +0000

description:
make sure we're holding the kernel lock when calling in to the usb code.

diffstat:

 sys/dev/usb/umidi.c |  21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diffs (61 lines):

diff -r cff6df51cc13 -r c7d57f21a2ce sys/dev/usb/umidi.c
--- a/sys/dev/usb/umidi.c       Mon Feb 13 01:47:16 2012 +0000
+++ b/sys/dev/usb/umidi.c       Mon Feb 13 01:51:02 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umidi.c,v 1.56 2012/02/07 11:40:24 plunky Exp $        */
+/*     $NetBSD: umidi.c,v 1.57 2012/02/13 01:51:02 mrg Exp $   */
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.56 2012/02/07 11:40:24 plunky Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.57 2012/02/13 01:51:02 mrg Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -366,11 +366,19 @@
 {
        struct umidi_mididev *mididev = addr;
 
+       /* XXX SMP */
+       KERNEL_LOCK(1, curlwp);
+       mutex_spin_exit(&mididev->sc->sc_lock);
+
        if ((mididev->flags & FWRITE) && mididev->out_jack)
                close_out_jack(mididev->out_jack);
        if ((mididev->flags & FREAD) && mididev->in_jack)
                close_in_jack(mididev->in_jack);
        mididev->opened = 0;
+
+       /* XXX SMP */
+       mutex_spin_enter(&mididev->sc->sc_lock);
+       KERNEL_UNLOCK_ONE(curlwp);
 }
 
 int
@@ -1003,6 +1011,11 @@
 static void
 unbind_jacks_from_mididev(struct umidi_mididev *mididev)
 {
+
+       /* XXX SMP */
+       KERNEL_LOCK(1, curlwp);
+       mutex_spin_exit(&mididev->sc->sc_lock);
+
        if ((mididev->flags & FWRITE) && mididev->out_jack)
                close_out_jack(mididev->out_jack);
        if ((mididev->flags & FREAD) && mididev->in_jack)
@@ -1013,6 +1026,10 @@
        if (mididev->in_jack)
                mididev->in_jack->binded = 0;
        mididev->out_jack = mididev->in_jack = NULL;
+
+       /* XXX SMP */
+       mutex_spin_enter(&mididev->sc->sc_lock);
+       KERNEL_UNLOCK_ONE(curlwp);
 }
 
 static void



Home | Main Index | Thread Index | Old Index