Commit 695df3c
fix(dwc2/hcd): guard against divide-by-zero when ep_size is 0
In cal_packet_count(), ep_size could be 0 if the device descriptor
returns bMaxPacketSize0 = 0 (due to buggy device or DMA cache
coherency issues), causing an integer divide-by-zero crash.
Two-layer fix:
- In hcd_edpt_open(): validate ep_size != 0 before allocating the
endpoint slot, returning false to let enumeration handle the error
gracefully rather than storing an invalid ep_size.
- In cal_packet_count(): guard ep_size == 0 as a last-resort safety
net to prevent a hard crash if an endpoint with zero ep_size is
somehow used for a transfer.
Fixes #3525
Co-authored-by: Ha Thach <hathach@users.noreply.github.com>1 parent cd7bbba commit 695df3c
1 file changed
+5
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
| 296 | + | |
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| |||
523 | 523 | | |
524 | 524 | | |
525 | 525 | | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
526 | 529 | | |
527 | 530 | | |
528 | 531 | | |
529 | 532 | | |
530 | 533 | | |
531 | 534 | | |
532 | | - | |
| 535 | + | |
533 | 536 | | |
534 | 537 | | |
535 | 538 | | |
| |||
0 commit comments