Skip to content

arch/arm: fix DMA transfers with sizes smaller than 4 bytes.#19206

Merged
acassis merged 1 commit into
apache:masterfrom
csanchezdll:fix_stm32_sendfifo
Jun 25, 2026
Merged

arch/arm: fix DMA transfers with sizes smaller than 4 bytes.#19206
acassis merged 1 commit into
apache:masterfrom
csanchezdll:fix_stm32_sendfifo

Conversation

@csanchezdll

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added Arch: arm Issues related to ARM (32-bit) architecture Size: XS The size of the change in this PR is very small labels Jun 24, 2026
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@acassis acassis requested a review from raiden00pl June 24, 2026 11:38
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>
@csanchezdll

Copy link
Copy Markdown
Contributor Author

Rebased to remove merge conflicts.

@acassis acassis merged commit 5feb1c4 into apache:master Jun 25, 2026
37 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants