Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb usb(4): Fix mistake in previous fix for pipe/int...



details:   https://anonhg.NetBSD.org/src/rev/138f8f35d1e4
branches:  trunk
changeset: 1021654:138f8f35d1e4
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Jun 12 14:57:53 2021 +0000

description:
usb(4): Fix mistake in previous fix for pipe/interface-change races.

Must block interface changes _before_ we enter usbd_setup_pipe_flags,
which calls the bus pipe open method.

diffstat:

 sys/dev/usb/usbdi.c |  14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diffs (38 lines):

diff -r 4145aa7b0002 -r 138f8f35d1e4 sys/dev/usb/usbdi.c
--- a/sys/dev/usb/usbdi.c       Sat Jun 12 14:43:27 2021 +0000
+++ b/sys/dev/usb/usbdi.c       Sat Jun 12 14:57:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi.c,v 1.208 2021/06/12 14:43:27 riastradh Exp $    */
+/*     $NetBSD: usbdi.c,v 1.209 2021/06/12 14:57:53 riastradh Exp $    */
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.208 2021/06/12 14:43:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.209 2021/06/12 14:57:53 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -241,12 +241,16 @@
        }
        return USBD_BAD_ADDRESS;
  found:
-       err = usbd_setup_pipe_flags(iface->ui_dev, iface, ep, ival, &p, flags);
-       if (err)
-               return err;
        mutex_enter(&iface->ui_pipelock);
        LIST_INSERT_HEAD(&iface->ui_pipes, p, up_next);
        mutex_exit(&iface->ui_pipelock);
+       err = usbd_setup_pipe_flags(iface->ui_dev, iface, ep, ival, &p, flags);
+       if (err) {
+               mutex_enter(&iface->ui_pipelock);
+               LIST_REMOVE(p, up_next);
+               mutex_exit(&iface->ui_pipelock);
+               return err;
+       }
        *pipe = p;
        SDT_PROBE5(usb, device, pipe, open,
            iface, address, flags, ival, p);



Home | Main Index | Thread Index | Old Index