mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
v4l2allocator: Add protection against broken libv4l2
It looks like libv4l2 support for CREATE_BUF is incomplete. That combine with existing bugs may lead to crash in GStreamer. These check will make it robust by: - Checking create buf index isn't an already in used index - Checking that the index out of QUERYBUF matches the requested index
This commit is contained in:
parent
6b2fc2de8d
commit
1fe4a19dc2
1 changed files with 18 additions and 0 deletions
|
@ -270,6 +270,14 @@ gst_v4l2_memory_group_new (GstV4l2Allocator * allocator, guint32 index)
|
|||
if (v4l2_ioctl (video_fd, VIDIOC_QUERYBUF, &group->buffer) < 0)
|
||||
goto querybuf_failed;
|
||||
|
||||
if (group->buffer.index != index) {
|
||||
GST_ERROR_OBJECT (allocator, "Buffer index returned by VIDIOC_QUERYBUF "
|
||||
"didn't match, this indicate the presence of a bug in your driver or "
|
||||
"libv4l2");
|
||||
g_slice_free (GstV4l2MemoryGroup, group);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Check that provided size matches the format we have negotiation. Failing
|
||||
* there usually means a driver of libv4l bug. */
|
||||
if (V4L2_TYPE_IS_MULTIPLANAR (allocator->type)) {
|
||||
|
@ -521,6 +529,9 @@ gst_v4l2_allocator_create_buf (GstV4l2Allocator * allocator)
|
|||
if (v4l2_ioctl (allocator->video_fd, VIDIOC_CREATE_BUFS, &bcreate) < 0)
|
||||
goto create_bufs_failed;
|
||||
|
||||
if (allocator->groups[bcreate.index] != NULL)
|
||||
goto create_bufs_bug;
|
||||
|
||||
group = gst_v4l2_memory_group_new (allocator, bcreate.index);
|
||||
|
||||
if (group) {
|
||||
|
@ -538,6 +549,13 @@ create_bufs_failed:
|
|||
g_strerror (errno));
|
||||
goto done;
|
||||
}
|
||||
create_bufs_bug:
|
||||
{
|
||||
GST_ERROR_OBJECT (allocator, "created buffer has already used buffer "
|
||||
"index %i, this means there is an bug in your driver or libv4l2",
|
||||
bcreate.index);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
static GstV4l2MemoryGroup *
|
||||
|
|
Loading…
Reference in a new issue