arch/arm: fix DMA transfers with sizes smaller than 4 bytes.#19206
Merged
Conversation
7237c4f to
546c382
Compare
xiaoxiang781216
previously approved these changes
Jun 24, 2026
When the buffer to send has a size not multiple of 4 bytes, 4-byte words are sent correctly, but when the code reaches the section to send the remaining bytes (1, 2 or 3) it was taking the remaining byte count as origin of the copy, instead of the buffer (as it should). This commit fixes it to correctly copy from the buffer pointer. Signed-off-by: Carlos Sanchez <carlossanchez@geotab.com>
546c382 to
2ac362f
Compare
Contributor
Author
|
Rebased to remove merge conflicts. |
xiaoxiang781216
approved these changes
Jun 25, 2026
acassis
approved these changes
Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
All STM32 SDIO/SDMMC drivers are affected by this bug which comes from the original addition of interrupt handing to the base STM32 SDIO driver in 2009 (373959f).
When the buffer to send has a size not multiple of 4 bytes, 4-byte words are sent correctly, but when the code reaches the section to send the remaining bytes (1, 2 or 3) it takes the remaining byte count as origin of the copy, instead of the buffer (as it should). The explicit cast (used to convert a uint32_t pointer to a uint8_t pointer) prevents the compiler warning/error to appear and hides the fact an integer (non-pointer) is used as a pointer.
Impact
This has been around since 2009 and has not triggered, probably because most (all?) SDIO transfers are word-sized so that section of the code is not being used at all.
Testing
The change has been tested on custom HW, using STM32H5, with STM32H7 SDMMC driver ported (it requires almost no changes to work on STM32H5). This has no effect (meaning: the driver still works after this change). I have not been able to find a use case triggering the bug, so I can not really test that this fixes it.