From: anton Date: Fri, 3 Dec 2021 06:34:38 +0000 (+0000) Subject: Bring back the recently reverted change, this time without the inverted X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e0050fab454da2f653d7391e25b21ab8c7753f01;p=openbsd Bring back the recently reverted change, this time without the inverted conditional. Repeating the previous commit messsage: Assert that at least one report id is claimed during multiple report ids attachment. Should prevent uhidev drivers from doing the wrong thing in their corresponding match routine. Tested by dv@ --- diff --git a/sys/dev/usb/uhidev.c b/sys/dev/usb/uhidev.c index 3d9d2b56164..66433a17097 100644 --- a/sys/dev/usb/uhidev.c +++ b/sys/dev/usb/uhidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhidev.c,v 1.105 2021/11/25 20:31:24 anton Exp $ */ +/* $OpenBSD: uhidev.c,v 1.106 2021/12/03 06:34:38 anton Exp $ */ /* $NetBSD: uhidev.c,v 1.14 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -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]) + if (sc->sc_subdevs[repid] == NULL) 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);