mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 01:53:29 +02:00
media: ipu6: Ensure stream_mutex is acquired when dealing with node list
The ipu6 isys driver maintains the list of video buffer queues related to a stream (in ipu6 context streams on the same CSI-2 virtual channel) and this list is modified through VIDIOC_STREAMON and VIDIOC_STREAMOFF IOCTLs. Ensure the common mutex is acquired when accessing the linked list, i.e. the isys device context's stream_mutex. Add a lockdep assert to ipu6_isys_get_buffer_list() and switch to guard() while at it as the error handling becomes more simple this way. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
parent
98cc19a353
commit
779bdaad2a
|
|
@ -3,6 +3,7 @@
|
|||
* Copyright (C) 2013--2024 Intel Corporation
|
||||
*/
|
||||
#include <linux/atomic.h>
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/bug.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/list.h>
|
||||
|
|
@ -201,6 +202,8 @@ static int buffer_list_get(struct ipu6_isys_stream *stream,
|
|||
unsigned long flags;
|
||||
unsigned long buf_flag = IPU6_ISYS_BUFFER_LIST_FL_INCOMING;
|
||||
|
||||
lockdep_assert_held(&stream->mutex);
|
||||
|
||||
bl->nbufs = 0;
|
||||
INIT_LIST_HEAD(&bl->head);
|
||||
|
||||
|
|
@ -294,9 +297,8 @@ static int ipu6_isys_stream_start(struct ipu6_isys_video *av,
|
|||
struct ipu6_isys_buffer_list __bl;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&stream->isys->stream_mutex);
|
||||
guard(mutex)(&stream->isys->stream_mutex);
|
||||
ret = ipu6_isys_video_set_streaming(av, 1, bl);
|
||||
mutex_unlock(&stream->isys->stream_mutex);
|
||||
if (ret)
|
||||
goto out_requeue;
|
||||
|
||||
|
|
@ -637,10 +639,10 @@ static void stop_streaming(struct vb2_queue *q)
|
|||
mutex_lock(&av->isys->stream_mutex);
|
||||
if (stream->nr_streaming == stream->nr_queues && stream->streaming)
|
||||
ipu6_isys_video_set_streaming(av, 0, NULL);
|
||||
list_del(&aq->node);
|
||||
mutex_unlock(&av->isys->stream_mutex);
|
||||
|
||||
stream->nr_streaming--;
|
||||
list_del(&aq->node);
|
||||
stream->streaming = 0;
|
||||
mutex_unlock(&stream->mutex);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user