Module Name:    src
Committed By:   jakllsch
Date:           Sat Jan 14 20:25:46 UTC 2012

Modified Files:
        src/sys/dev/usb: ucom.c

Log Message:
In ucompoll() also bail out if we don't have a valid softc.
Seems to prevent occasional crashes when a open ucom is removed.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/dev/usb/ucom.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/usb/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.93 src/sys/dev/usb/ucom.c:1.94
--- src/sys/dev/usb/ucom.c:1.93	Fri Dec 23 00:51:45 2011
+++ src/sys/dev/usb/ucom.c	Sat Jan 14 20:25:45 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucom.c,v 1.93 2011/12/23 00:51:45 jakllsch Exp $	*/
+/*	$NetBSD: ucom.c,v 1.94 2012/01/14 20:25:45 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.93 2011/12/23 00:51:45 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.94 2012/01/14 20:25:45 jakllsch Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -656,13 +656,16 @@ ucomwrite(dev_t dev, struct uio *uio, in
 int
 ucompoll(dev_t dev, int events, struct lwp *l)
 {
-	struct ucom_softc *sc = device_lookup_private(&ucom_cd, UCOMUNIT(dev));
-	struct tty *tp = sc->sc_tty;
+	struct ucom_softc *sc;
+	struct tty *tp;
 	int revents;
 
-	if (sc->sc_dying)
+	sc = device_lookup_private(&ucom_cd, UCOMUNIT(dev));
+	if (sc == NULL || sc->sc_dying)
 		return (POLLHUP);
 
+	tp = sc->sc_tty;
+
 	sc->sc_refcnt++;
 	revents = ((*tp->t_linesw->l_poll)(tp, events, l));
 	if (--sc->sc_refcnt < 0)

Reply via email to