Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Dec 2012 16:21:03 +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: r244489 - head/sys/dev/usb/serial
Message-ID:  <201212201621.qBKGL3kp079167@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Thu Dec 20 16:21:02 2012
New Revision: 244489
URL: http://svnweb.freebsd.org/changeset/base/244489

Log:
  Make sure we block recursion on TTY's inwakeup callback
  
  Suggested by:	davide
  MFC after:	1 week

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

Modified: head/sys/dev/usb/serial/usb_serial.c
==============================================================================
--- head/sys/dev/usb/serial/usb_serial.c	Thu Dec 20 13:27:43 2012	(r244488)
+++ head/sys/dev/usb/serial/usb_serial.c	Thu Dec 20 16:21:02 2012	(r244489)
@@ -797,10 +797,14 @@ ucom_inwakeup(struct tty *tp)
 	DPRINTF("tp=%p\n", tp);
 
 	if (ttydisc_can_bypass(tp) != 0 || 
-	    (sc->sc_flag & UCOM_FLAG_HL_READY) == 0) {
+	    (sc->sc_flag & UCOM_FLAG_HL_READY) == 0 ||
+	    (sc->sc_flag & UCOM_FLAG_INWAKEUP) != 0) {
 		return;
 	}
 
+	/* prevent recursion */
+	sc->sc_flag |= UCOM_FLAG_INWAKEUP;
+
 	pos = sc->sc_jitterbuf_out;
 
 	while (sc->sc_jitterbuf_in != pos) {
@@ -821,6 +825,8 @@ ucom_inwakeup(struct tty *tp)
 	if ((sc->sc_jitterbuf_in == pos) && 
 	    (sc->sc_flag & UCOM_FLAG_RTS_IFLOW))
 		ucom_rts(sc, 0);
+
+	sc->sc_flag &= ~UCOM_FLAG_INWAKEUP;
 }
 
 static int

Modified: head/sys/dev/usb/serial/usb_serial.h
==============================================================================
--- head/sys/dev/usb/serial/usb_serial.h	Thu Dec 20 13:27:43 2012	(r244488)
+++ head/sys/dev/usb/serial/usb_serial.h	Thu Dec 20 16:21:02 2012	(r244489)
@@ -183,6 +183,7 @@ struct ucom_softc {
 #define	UCOM_FLAG_CONSOLE	0x80	/* set if device is a console */
 #define	UCOM_FLAG_WAIT_REFS   0x0100	/* set if we must wait for refs */
 #define	UCOM_FLAG_FREE_UNIT   0x0200	/* set if we must free the unit */
+#define	UCOM_FLAG_INWAKEUP    0x0400	/* set if we are in the tsw_inwakeup callback */
 	uint8_t	sc_lsr;
 	uint8_t	sc_msr;
 	uint8_t	sc_mcr;



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