Module Name:    src
Committed By:   manu
Date:           Thu Nov  8 01:59:53 UTC 2018

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

Log Message:
Enfore USB timeout on ugen(4) write operations


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 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.140 src/sys/dev/usb/ugen.c:1.141
--- src/sys/dev/usb/ugen.c:1.140	Mon Sep  3 16:29:34 2018
+++ src/sys/dev/usb/ugen.c	Thu Nov  8 01:59:53 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ugen.c,v 1.140 2018/09/03 16:29:34 riastradh Exp $	*/
+/*	$NetBSD: ugen.c,v 1.141 2018/11/08 01:59:53 manu 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.140 2018/09/03 16:29:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.141 2018/11/08 01:59:53 manu Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1456,6 +1456,7 @@ ugen_do_ioctl(struct ugen_softc *sc, int
 	uint8_t conf, alt;
 	int cdesclen;
 	int error;
+	int dir;
 
 	DPRINTFN(5, ("ugenioctl: cmd=%08lx\n", cmd));
 	if (sc->sc_dying)
@@ -1478,14 +1479,13 @@ ugen_do_ioctl(struct ugen_softc *sc, int
 			sce->state &= ~UGEN_SHORT_OK;
 		return 0;
 	case USB_SET_TIMEOUT:
-		sce = &sc->sc_endpoints[endpt][IN];
-		if (sce == NULL
-		    /* XXX this shouldn't happen, but the distinction between
-		       input and output pipes isn't clear enough.
-		       || sce->pipeh == NULL */
-			)
-			return EINVAL;
-		sce->timeout = *(int *)addr;
+		for (dir = OUT; dir <= IN; dir++) {
+			sce = &sc->sc_endpoints[endpt][dir];
+			if (sce == NULL)
+				return EINVAL;
+
+			sce->timeout = *(int *)addr;
+		}
 		return 0;
 	case USB_SET_BULK_RA:
 		if (endpt == USB_CONTROL_ENDPOINT)

Reply via email to