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

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