Subject: Re: USB connect/removal events
To: Lennart Augustsson <lennart@mail.augustsson.net>
From: Christian Groessler <cpg@aladdin.de>
List: current-users
Date: 09/21/2000 23:32:57
Hi,

while checking out your program to detect USB device changes, I found
a bug in the kernel.

I tried with a device where no NetBSD USB driver is available (so
connecting it
gives a message "...blablabla.. not configured").

If I detach the device everything is working, but when I detach the hub the
device is connected to the kernel panics.

It crashes in the uhub_activate function, and after a little debugging I
came
up with the following change to prevent the panic:

---------------
--- uhub.c.org Thu Jun  1 16:29:00 2000
+++ uhub.c     Fri Sep 22 00:17:01 2000
@@ -472,7 +472,7 @@
          for(port = 0; port < nports; port++) {
               dev = hub->ports[port].device;
               if (dev != NULL) {
-                   for (i = 0; dev->subdevs[i]; i++)
+                   for (i = 0; dev->subdevs && dev->subdevs[i]; i++)
                         config_deactivate(dev->subdevs[i]);
               }
          }
---------------

If this is OK, please check it into the cvs tree. ..

regards,
chris