Repository navigation
pjmedia-videodev: fix use-after-free crash in v4l2_scan_devs() - #5327
Merged
Merged
Conversation
nanangizz
approved these changes
Oct 8, 2026
nanangizz
left a comment
Member
There was a problem hiding this comment.
Thanks, both changes look right. Clearing dev_info after the pool release makes the allocation unconditional, so a refresh with the same or fewer devices no longer copies into the released pool. And pdi->info.fmt_cnt == 0 replaces a check that could never be true (j == fmt_cnt after the size loop), so a device without any usable size is no longer listed with an empty format list.
Optional: with dev_info always NULL at that point, f->dev_count > old_count || f->dev_info == NULL is always true, so the condition and old_count could be dropped and the array allocated unconditionally.
sauwming
approved these changes
Oct 8, 2026
nanangizz
approved these changes
Oct 9, 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.
Closes #5326
v4l2_scan_devs()releasesdev_poolduring refresh but leavesdev_infopointing to freed memory. When the device count stays the same or decreases, allocation can be skipped, causing writes to freed memory and subsequent crashes during format enumeration.This MR:
dev_infotoNULLafter releasing its pool, ensuring a fresh device array is allocated.j < fmt_cntcheck withpdi->info.fmt_cnt == 0, preventing devices without usable formats from being advertised.Tested in the affected application and confirmed that the changes prevent the previously observed crash.