diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index 4266a0cb7..b1b358b3a 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c @@ -2458,12 +2458,21 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf, struct uea_softc *sc; int ret, ifnum = intf->altsetting->desc.bInterfaceNumber; unsigned int alt; + int modem_idx; /* interface 0 is for firmware/monitoring */ if (ifnum != UEA_INTR_IFACE_NO) return -ENODEV; - usbatm->flags = (sync_wait[modem_index] ? 0 : UDSL_SKIP_HEAVY_INIT); + /* + * modem_index is a global counter that stops at NB_MODEM once that + * many devices have been probed. Wrap the index the same way as + * sc->modem_index below so that the module parameter lookup stays + * within the bounds of the arrays. + */ + modem_idx = (modem_index < NB_MODEM) ? modem_index : 0; + + usbatm->flags = (sync_wait[modem_idx] ? 0 : UDSL_SKIP_HEAVY_INIT); /* interface 1 is for outbound traffic */ ret = claim_interface(usb, usbatm, UEA_US_IFACE_NO);