Module Name:    src
Committed By:   pooka
Date:           Fri Feb 19 12:40:47 UTC 2010

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

Log Message:
Replace USB_GET_SC() instances with USB_GET_SC_OPEN().  The latter
is exactly like the former, except it returns with ENXIO if sc is
NULL instead of continuing on to use it.  Most of the time this is
handled by the fd layer and you get EBADF, but sometimes it's
possible to race into the device method for whatever reason and
you get a kernel panic.  I have no idea what the "whatever reason"
might be.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/sys/dev/usb/ugen.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/ugen.c
diff -u src/sys/dev/usb/ugen.c:1.108 src/sys/dev/usb/ugen.c:1.109
--- src/sys/dev/usb/ugen.c:1.108	Thu Dec 24 01:32:22 2009
+++ src/sys/dev/usb/ugen.c	Fri Feb 19 12:40:47 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: ugen.c,v 1.108 2009/12/24 01:32:22 jakllsch Exp $	*/
+/*	$NetBSD: ugen.c,v 1.109 2010/02/19 12:40:47 pooka Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.108 2009/12/24 01:32:22 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.109 2010/02/19 12:40:47 pooka Exp $");
 
 #include "opt_compat_netbsd.h"
 
@@ -507,7 +507,7 @@
 	int dir;
 	int i;
 
-	USB_GET_SC(ugen, UGENUNIT(dev), sc);
+	USB_GET_SC_OPEN(ugen, UGENUNIT(dev), sc);
 
 	DPRINTFN(5, ("ugenclose: flag=%d, mode=%d, unit=%d, endpt=%d\n",
 		     flag, mode, UGENUNIT(dev), endpt));
@@ -786,7 +786,7 @@
 	struct ugen_softc *sc;
 	int error;
 
-	USB_GET_SC(ugen, UGENUNIT(dev), sc);
+	USB_GET_SC_OPEN(ugen, UGENUNIT(dev), sc);
 
 	sc->sc_refcnt++;
 	error = ugen_do_read(sc, endpt, uio, flag);
@@ -969,7 +969,7 @@
 	struct ugen_softc *sc;
 	int error;
 
-	USB_GET_SC(ugen, UGENUNIT(dev), sc);
+	USB_GET_SC_OPEN(ugen, UGENUNIT(dev), sc);
 
 	sc->sc_refcnt++;
 	error = ugen_do_write(sc, endpt, uio, flag);
@@ -1823,7 +1823,7 @@
 	struct ugen_softc *sc;
 	int error;
 
-	USB_GET_SC(ugen, UGENUNIT(dev), sc);
+	USB_GET_SC_OPEN(ugen, UGENUNIT(dev), sc);
 
 	sc->sc_refcnt++;
 	error = ugen_do_ioctl(sc, endpt, cmd, addr, flag, l);
@@ -1840,7 +1840,7 @@
 	int revents = 0;
 	int s;
 
-	USB_GET_SC(ugen, UGENUNIT(dev), sc);
+	USB_GET_SC_OPEN(ugen, UGENUNIT(dev), sc);
 
 	if (sc->sc_dying)
 		return (POLLHUP);
@@ -2025,7 +2025,7 @@
 	struct klist *klist;
 	int s;
 
-	USB_GET_SC(ugen, UGENUNIT(dev), sc);
+	USB_GET_SC_OPEN(ugen, UGENUNIT(dev), sc);
 
 	if (sc->sc_dying)
 		return (ENXIO);

Reply via email to