]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
media: videobuf2-core: take mmap_lock in vb2_get_unmapped_area()
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 7 Dec 2022 13:04:34 +0000 (13:04 +0000)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 14 Dec 2022 13:02:54 +0000 (14:02 +0100)
commit75f1d9f77ccbbc5a95daa96aa2350643af4fce08
treecf5aee1b58e3208397a1e871f4c7831f500aad6f
parentebd228a350bf75fd192cf77c8e55baa3c5954ba7
media: videobuf2-core: take mmap_lock in vb2_get_unmapped_area()

[ Upstream commit 098e5edc5d048a8df8691fd9fde895af100be42b ]

While vb2_mmap took the mmap_lock mutex, vb2_get_unmapped_area didn't.
Add this.

Also take this opportunity to move the 'q->memory != VB2_MEMORY_MMAP'
check and vb2_fileio_is_active() check into __find_plane_by_offset() so
both vb2_mmap and vb2_get_unmapped_area do the same checks.

Since q->memory is checked while mmap_lock is held, also take that lock
in reqbufs and create_bufs when it is set, and set it back to
MEMORY_UNKNOWN on error.

Fixes: f035eb4e976e ("[media] videobuf2: fix lockdep warning")
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 22d800b378e45ca1415b6e5e00665131be3721a2)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
drivers/media/common/videobuf2/videobuf2-core.c