From cdfeaa356d758f80dd4d2d5fef6bcda83bd0a45b Mon Sep 17 00:00:00 2001 From: manu Date: Thu, 8 Nov 2018 01:59:53 +0000 Subject: Enfore USB timeout on ugen(4) write operations --- sys/dev/usb/ugen.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c index a97e9b3b690..790ceb25313 100644 --- a/sys/dev/usb/ugen.c +++ b/sys/dev/usb/ugen.c @@ -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 -__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 endpt, u_long cmd, 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 endpt, u_long cmd, 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) -- cgit