Panic on control buffer overflow#95
Open
haata wants to merge 1 commit intorust-embedded-community:masterfrom
Open
Panic on control buffer overflow#95haata wants to merge 1 commit intorust-embedded-community:masterfrom
haata wants to merge 1 commit intorust-embedded-community:masterfrom
Conversation
- When writing larger interface descriptors it's possible to overflow
the buffer (even on LS/FS USB 2.0)
- Cleanup get_descriptor and accept_writer to forward the error
- Then unwrap() it inside get_descriptor
* unwrap() will panic regardless of the logging mechanism and give a
useful error message (e.g. defmt):
ERROR panicked at 'called `Result::unwrap()` on an `Err` value: BufferOverflow'
* We want to panic as continuing usually halts/suspends the USB
device which will usually retry enumeration a few times until the
host gives up
* This is most common during initial enumeration, but it's also
possible when requesting debug descriptors (e.g. lsusb)
- Ideally we should return some sort of error that recommends enabling
the control-buffer-256 feature but this isn't straightforward with the
current design
ryan-summers
requested changes
Jun 5, 2022
Member
ryan-summers
left a comment
There was a problem hiding this comment.
Thanks for the fix PR!
Can you please add a CHANGELOG entry for the fix?
It would also be helpful to file an issue to describe the defect that you're seeing. After reviewing the code, I think I understand, but it wasn't immediately clear to me from the start.
In any case, this one wasn't too hard to figure out, but it would be helpful for others looking for fixes and/or looking up similar errors in the future :)
| } | ||
| _ => xfer.reject(), | ||
| } | ||
| .unwrap(); |
Member
There was a problem hiding this comment.
I don't think unwrap()ing the result here is the best approach. This will inject fmt bloat into applications for people that may not be able to pay the memory overhead.
We should likely bubble the error up instead and let the user handle the Result
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.
the buffer (even on LS/FS USB 2.0)
useful error message (e.g. defmt):
ERROR panicked at 'called
Result::unwrap()on anErrvalue: BufferOverflow'device which will usually retry enumeration a few times until the
host gives up
possible when requesting debug descriptors (e.g. lsusb)
the control-buffer-256 feature but this isn't straightforward with the
current design