mirror of
https://github.com/torvalds/linux.git
synced 2026-09-13 15:40:03 +02:00
media: v4l2-h264: Fix memcmp() size in B1 reference list comparison
In v4l2_h264_build_b_ref_lists(), the B0/B1 list equality
check passes the entry count builder->num_valid to memcmp()
instead of a byte size. Since struct v4l2_h264_reference is
two bytes (fields and index), only half of each list is
compared, so distinct lists can be wrongly treated as equal
and trigger an incorrect swap(b1_reflist[0], b1_reflist[1]).
Change the memcmp() size argument to sizeof(b1_reflist[0]) *
builder->num_valid so that the full byte length of both
reference lists is compared.
Fixes: 624922a273 ("media: v4l2-core: Add helpers to build the H264 P/B0/B1 reflists")
Suggested-by: Nicolas Dufresne <nicolas@ndufresne.ca>
Cc: stable@vger.kernel.org
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
parent
e04ffff543
commit
10e59fbdef
|
|
@ -440,7 +440,8 @@ v4l2_h264_build_b_ref_lists(const struct v4l2_h264_reflist_builder *builder,
|
|||
}
|
||||
|
||||
if (builder->num_valid > 1 &&
|
||||
!memcmp(b1_reflist, b0_reflist, builder->num_valid))
|
||||
!memcmp(b1_reflist, b0_reflist,
|
||||
sizeof(b1_reflist[0]) * builder->num_valid))
|
||||
swap(b1_reflist[0], b1_reflist[1]);
|
||||
|
||||
print_ref_list_b(builder, b0_reflist, 0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user