Skip to content

Commit 27afd6e

Browse files
mszyprowHans Verkuil
authored andcommitted
media: videobuf2: forbid remove_bufs when legacy fileio is active
vb2_ioctl_remove_bufs() call manipulates queue internal buffer list, potentially overwriting some pointers used by the legacy fileio access mode. Forbid that ioctl when fileio is active to protect internal queue state between subsequent read/write calls. CC: stable@vger.kernel.org Fixes: a3293a8 ("media: v4l2: Add REMOVE_BUFS ioctl") Reported-by: Shuangpeng Bai <SJB7183@psu.edu> Closes: https://lore.kernel.org/linux-media/5317B590-AAB4-4F17-8EA1-621965886D49@psu.edu/ Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
1 parent 758dbc7 commit 27afd6e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/media/common/videobuf2/videobuf2-v4l2.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,11 @@ int vb2_ioctl_remove_bufs(struct file *file, void *priv,
10101010
if (vb2_queue_is_busy(vdev->queue, file))
10111011
return -EBUSY;
10121012

1013+
if (vb2_fileio_is_active(vdev->queue)) {
1014+
dprintk(vdev->queue, 1, "file io in progress\n");
1015+
return -EBUSY;
1016+
}
1017+
10131018
return vb2_core_remove_bufs(vdev->queue, d->index, d->count);
10141019
}
10151020
EXPORT_SYMBOL_GPL(vb2_ioctl_remove_bufs);

0 commit comments

Comments
 (0)