]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: video-i2c: fix buffer queue ordering
authorArash Golgol <arash.golgol@gmail.com>
Sun, 10 May 2026 03:34:23 +0000 (07:04 +0330)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Tue, 12 May 2026 07:39:02 +0000 (09:39 +0200)
Queued buffers are added to the tail of vid_cap_active in
buffer_queue(), but the capture kthread also retrieves buffers from
the tail of the list.

This makes the queue behave as LIFO instead of FIFO when multiple
buffers are queued.

Fix this by retrieving buffers from the head of the list.

Signed-off-by: Arash Golgol <arash.golgol@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/i2c/video-i2c.c

index 9c47f4aaa359deb3f7e4718bf378050a7699c1c8..2b23914717d17bceb17d9a6e21a8a514cc63ad46 100644 (file)
@@ -454,8 +454,9 @@ static int video_i2c_thread_vid_cap(void *priv)
                spin_lock(&data->slock);
 
                if (!list_empty(&data->vid_cap_active)) {
-                       vid_cap_buf = list_last_entry(&data->vid_cap_active,
-                                                struct video_i2c_buffer, list);
+                       vid_cap_buf = list_first_entry(&data->vid_cap_active,
+                                                      struct video_i2c_buffer,
+                                                      list);
                        list_del(&vid_cap_buf->list);
                }