Fix UVC gadget support on 32-bit systems #6095
Closed
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.
Note that this is clearly a common upstream problem, not specific to Raspberry Pi. I will work with mainline kernel to get this upstreamed (when I figure out how to do so :)), which will take quite some time.
Given that currently UVC gadget support is completely broken on 6.6 32-bit kernel, I believe that this is valuable for the community to be included into Raspberry Pi kernels sooner than doing it in the roundabout way through upstream.
The problem description follows:
Commit 0df2860 introduced a helper function to parse commonly occurring strings containing lists of numbers. Original functions used
buf
buffer on stack, and queried its size usingsizeof(buf)
to avoid overrun. The newly intruduced function, however, used a dynamically sized heap-allocated buffer, but wasn't updated to use this new buffer size instead of just sizeof.Therefore, parsing now can only read items of size 3 max on 32-bit systems, and of size 7 on 64-bit ones. Some UVC fields do need numbers with more digits, e.g.
dwFrameInteval
needs at least 5-6, so it fails to be written into, thus completely breaking UVC gadget support on 32 bit systems.