Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usb: fix wrong capacity report for USB mass storage device #77597

Conversation

jfischer-no
Copy link
Collaborator

@jfischer-no jfischer-no commented Aug 27, 2024

cherry-picked 32481b6 from #77173
Fixes #77175.

Usb "write" method never copies the input data buffer, it uses the
buffer pointer directly. The fact that it was on the stack made
the buffer ephemeral, and could disappear before the USB transfer
actually occurred. The data transmitted was then random. This commit
converts the transfer buffer to a static buffer, so that it always
exists for the duration of the USB transfer.

Known side-effect: if "read capacity" command is read twice
simultaneously, the same buffer will be used twice. As the capacity of a
USB drive should not change between 2 calls, this side effect can be
ignored.

Signed-off-by: Alexi Demers <alexi.demers@axceta.com>
(cherry picked from commit 32481b6)
@jfischer-no jfischer-no added the backport v3.7-branch Request backport to the v3.7-branch label Aug 27, 2024
@zephyrbot zephyrbot added size: XS A PR changing only a single line of code area: USB Universal Serial Bus labels Aug 27, 2024
@fabiobaltieri fabiobaltieri merged commit b26773f into zephyrproject-rtos:v3.7-branch Oct 2, 2024
29 of 31 checks passed
@jfischer-no jfischer-no deleted the pr-backport-32481b64185205222a58acdc6e7272ef2c06869d branch October 2, 2024 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus backport v3.7-branch Request backport to the v3.7-branch size: XS A PR changing only a single line of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants