Hi,
This will prevent a driver attaching on top of uhidev from doing the
wrong thing in response to a claim multiple report ids match request.
Returning non-zero from such request must imply that at least one report
id is claimed. This would have caught some of the uhidev problems fixed
at this point.

Comments? OK?

diff --git sys/dev/usb/uhidev.c sys/dev/usb/uhidev.c
index 3526e4cb86e..258395af898 100644
--- sys/dev/usb/uhidev.c
+++ sys/dev/usb/uhidev.c
@@ -256,16 +256,21 @@ uhidev_attach(struct device *parent, struct device *self, 
void *aux)
        /* Look for a driver claiming multiple report IDs first. */
        dev = config_found_sm(self, &uha, NULL, NULL);
        if (dev != NULL) {
+               int nclaimed = 0;
+
                for (repid = 0; repid < nrepid; repid++) {
+                       if (!uha.claimed[repid])
+                               continue;
+
+                       nclaimed++;
                        /*
                         * Could already be assigned by uhidev_set_report_dev().
                         */
                        if (sc->sc_subdevs[repid] != NULL)
-                               continue;
-
-                       if (uha.claimed[repid])
                                sc->sc_subdevs[repid] = (struct uhidev *)dev;
                }
+               KASSERTMSG(nclaimed > 0, "%s did not claim any report ids",
+                   dev->dv_xname);
        }
 
        free(uha.claimed, M_TEMP, nrepid);

Reply via email to