Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Nov 2012 18:44:05 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r242702 - head/sys/dev/usb/serial
Message-ID:  <201211071844.qA7Ii5e9083057@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Wed Nov  7 18:44:05 2012
New Revision: 242702
URL: http://svnweb.freebsd.org/changeset/base/242702

Log:
  The tty_inwakeup callback appears to be called both locked and unlocked.
  Handle the required locking automatically for now.
  
  MFC after:	1 weeks

Modified:
  head/sys/dev/usb/serial/usb_serial.c

Modified: head/sys/dev/usb/serial/usb_serial.c
==============================================================================
--- head/sys/dev/usb/serial/usb_serial.c	Wed Nov  7 17:41:17 2012	(r242701)
+++ head/sys/dev/usb/serial/usb_serial.c	Wed Nov  7 18:44:05 2012	(r242702)
@@ -788,15 +788,20 @@ ucom_inwakeup(struct tty *tp)
 {
 	struct ucom_softc *sc = tty_softc(tp);
 	uint16_t pos;
+	int locked;
 
 	if (sc == NULL)
 		return;
 
-	tty_lock(tp);
+	locked = mtx_owned(sc->sc_mtx);
+
+	if (locked == 0)
+		tty_lock(tp);
 
 	if (ttydisc_can_bypass(tp) != 0 || 
 	    (sc->sc_flag & UCOM_FLAG_HL_READY) == 0) {
-		tty_unlock(tp);
+		if (locked == 0)
+			tty_unlock(tp);
 		return;
 	}
 
@@ -821,7 +826,8 @@ ucom_inwakeup(struct tty *tp)
 	    (sc->sc_flag & UCOM_FLAG_RTS_IFLOW))
 		ucom_rts(sc, 0);
 
-	tty_unlock(tp);
+	if (locked == 0)
+		tty_unlock(tp);
 }
 
 static int



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211071844.qA7Ii5e9083057>