diff --git a/drivers/net/wireless/ath/ar5523/ar5523.c b/drivers/net/wireless/ath/ar5523/ar5523.c index 6f937d2cc126..5451bf9ab9fb 100644 --- a/drivers/net/wireless/ath/ar5523/ar5523.c +++ b/drivers/net/wireless/ath/ar5523/ar5523.c @@ -1581,8 +1581,39 @@ static int ar5523_probe(struct usb_interface *intf, struct usb_device *dev = interface_to_usbdev(intf); struct ieee80211_hw *hw; struct ar5523 *ar; + struct usb_host_interface *host = intf->cur_altsetting; int error = -ENOMEM; + if (host->desc.bNumEndpoints != 4){ + dev_err(&dev->dev, "Wrong number of endpoints\n"); + return -ENODEV; + } + + for (int i = 0; i < host->desc.bNumEndpoints; ++i){ + struct usb_endpoint_descriptor *ep = &host->endpoint[i].desc; + // Check for type of endpoint and direction. + switch(i){ + case 0: + case 1: + if((ep->bEndpointAddress & USB_DIR_OUT) && + ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) + == USB_ENDPOINT_XFER_BULK)){ + dev_err(&dev->dev, "Wrong type of endpoints\n"); + return -ENODEV; + } + break; + case 2: + case 3: + if((ep->bEndpointAddress & USB_DIR_IN) && + ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) + == USB_ENDPOINT_XFER_BULK)){ + dev_err(&dev->dev, "Wrong type of endpoints\n"); + return -ENODEV; + } + break; + } + } + /* * Load firmware if the device requires it. This will return * -ENXIO on success and we'll get called back afer the usb