Re: [PATCH v2] usb: prevent duplicate bEndpointAddress by usb_ep_autoconfig_ss (bitmap).

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

 



On Thu, Apr 27, 2023 at 05:36:34PM +0200, Wlodzimierz Lipert wrote:
> Indeed, easier to follow. What you think about adding the check (below),
> IMHO we should not test bits outside of valid range, and it will cover
> bugs in ep name.

> >         if (isdigit(ep->name[2])) {             /* Number encoded in name */
> >                 num = simple_strtoul(&ep->name[2], NULL, 10);
>                  if (num > 15 || *epmap & (1 << num))
> >                         return NULL;            /* Endpoint is unavailable */

We don't want to cover up bugs; we want to _fix_ them.  That's why I 
suggested adding a WARN_ON(), so that people will be aware there's a bug 
that needs fixing.  If you prefer, you could do it like this:

		if (num > 15) {
			WARN_ON(1);	/* Invalid endpoint number */
			return NULL;
		}
		if (*epmap & (1 << num))
			return NULL;	/* Endpoint is unavailable */

That would be okay.

Alan Stern



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux