Commit 731f7ad
stm32/sdcard: Fix unchecked uint32_t overflow in SD card driver.
Manifests as `readblocks(-1, buf)` failing. The ST HAL does a bounds
check, but it checks `(block_num + num_blocks)` is within bounds, so if
these values overflow then it allows the read which seems to hang some SD
Cards (but not all).
Fix by explicitly testing for overflow in our layer of the driver.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <[email protected]>1 parent 8ce7a58 commit 731f7ad
1 file changed
+19
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
498 | 498 | | |
499 | 499 | | |
500 | 500 | | |
501 | | - | |
| 501 | + | |
502 | 502 | | |
503 | 503 | | |
504 | 504 | | |
505 | 505 | | |
506 | 506 | | |
507 | | - | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
508 | 522 | | |
509 | 523 | | |
510 | 524 | | |
| |||
595 | 609 | | |
596 | 610 | | |
597 | 611 | | |
598 | | - | |
599 | | - | |
600 | | - | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
601 | 615 | | |
602 | 616 | | |
603 | | - | |
604 | | - | |
605 | 617 | | |
606 | 618 | | |
607 | 619 | | |
| |||
0 commit comments