m66591: Fix out-of-bounds array access

Loop terminator needed a preincrement rather than postincrement, and
also used a proper #define instead of a magic number.

Change-Id: Iafd6a0dce0304cb94e4f1d04cce46d2ca603507a
This commit is contained in:
Solomon Peachy 2020-05-12 15:15:05 -04:00
parent b450707955
commit f0ac5d123f

View file

@ -659,13 +659,13 @@ int usb_drv_request_endpoint(int type, int dir) {
}
} else if (type == USB_ENDPOINT_XFER_INT) {
ep=5;
pipecfg |= 1<<13;
while(M66591_eps[ep].busy && ep++<7);
/* If this reached 7 the endpoints were all busy */
if(ep==7) {
pipecfg |= 1<<13;
while(M66591_eps[ep].busy && ++ep<USB_NUM_ENDPOINTS);
/* If this reached USB_NUM_ENDPOINTS the endpoints were all busy */
if(ep==USB_NUM_ENDPOINTS) {
logf("mxx: ep %d busy", ep);
return -1;
}