Source-Changes-HG archive

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

[src/nick-nhusb]: src/sys/dev/usb Fix slot leak when address_device fails.



details:   https://anonhg.NetBSD.org/src/rev/dbd9fc6a1e76
branches:  nick-nhusb
changeset: 334210:dbd9fc6a1e76
user:      skrll <skrll%NetBSD.org@localhost>
date:      Wed May 27 07:03:18 2015 +0000

description:
Fix slot leak when address_device fails.

>From Takahiro HAYASHI.

diffstat:

 sys/dev/usb/xhci.c |  12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diffs (33 lines):

diff -r 1f2b2b50d6f7 -r dbd9fc6a1e76 sys/dev/usb/xhci.c
--- a/sys/dev/usb/xhci.c        Wed May 27 06:56:16 2015 +0000
+++ b/sys/dev/usb/xhci.c        Wed May 27 07:03:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xhci.c,v 1.28.2.22 2015/05/27 06:56:16 skrll Exp $     */
+/*     $NetBSD: xhci.c,v 1.28.2.23 2015/05/27 07:03:18 skrll Exp $     */
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.22 2015/05/27 06:56:16 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.28.2.23 2015/05/27 07:03:18 skrll Exp $");
 
 #include "opt_usb.h"
 
@@ -2065,6 +2065,14 @@
                err = xhci_init_slot(dev, slot, route, rhport);
                if (err) {
                        dev->ud_hcpriv = NULL;
+                       /*
+                        * We have to disable_slot here because
+                        * xs->xs_idx == 0 when xhci_init_slot fails,
+                        * in that case usbd_remove_dev won't work.
+                        */
+                       mutex_enter(&sc->sc_lock);
+                       xhci_disable_slot(sc, slot);
+                       mutex_exit(&sc->sc_lock);
                        goto bad;
                }
 



Home | Main Index | Thread Index | Old Index