public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hsia-Jun Li <randy.li@synaptics.com>
To: linux-media@vger.kernel.org
Cc: mchehab@kernel.org, hverkuil-cisco@xs4all.nl,
	sebastian.fricke@collabora.com, nicolas.dufresne@collabora.com,
	alexious@zju.edu.cn, ayaka@soulik.info,
	linux-kernel@vger.kernel.org,
	"Hsia-Jun(Randy) Li" <randy.li@synaptics.com>
Subject: [PATCH] media: v4l2-mem2mem: fix mem order in last buf
Date: Sun, 11 Feb 2024 02:04:06 +0800	[thread overview]
Message-ID: <20240210180414.49184-1-randy.li@synaptics.com> (raw)

From: "Hsia-Jun(Randy) Li" <randy.li@synaptics.com>

The has_stopped property in struct v4l2_m2m_ctx is operated
without a lock protecction. Then the userspace calls to
v4l2_m2m_encoder_cmd()/v4l2_m2m_decoder_cmd() may lead to
a critical section issue.

Signed-off-by: Hsia-Jun(Randy) Li <randy.li@synaptics.com>
---
 drivers/media/v4l2-core/v4l2-mem2mem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-mem2mem.c b/drivers/media/v4l2-core/v4l2-mem2mem.c
index 75517134a5e9..f1de71031e02 100644
--- a/drivers/media/v4l2-core/v4l2-mem2mem.c
+++ b/drivers/media/v4l2-core/v4l2-mem2mem.c
@@ -635,9 +635,9 @@ void v4l2_m2m_last_buffer_done(struct v4l2_m2m_ctx *m2m_ctx,
 			       struct vb2_v4l2_buffer *vbuf)
 {
 	vbuf->flags |= V4L2_BUF_FLAG_LAST;
-	vb2_buffer_done(&vbuf->vb2_buf, VB2_BUF_STATE_DONE);
-
 	v4l2_m2m_mark_stopped(m2m_ctx);
+
+	vb2_buffer_done(&vbuf->vb2_buf, VB2_BUF_STATE_DONE);
 }
 EXPORT_SYMBOL_GPL(v4l2_m2m_last_buffer_done);
 
-- 
2.17.1


             reply	other threads:[~2024-02-10 18:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-10 18:04 Hsia-Jun Li [this message]
2024-02-14 20:38 ` [PATCH] media: v4l2-mem2mem: fix mem order in last buf Nicolas Dufresne
2024-02-15  3:16   ` Randy Li
2024-02-15  8:41     ` Hans Verkuil
2024-02-16 19:09       ` Nicolas Dufresne
2024-02-21 10:37         ` Hsia-Jun Li
2024-02-21 15:32           ` Nicolas Dufresne
2024-02-22  6:45             ` Hsia-Jun Li
2024-02-16 18:56     ` Nicolas Dufresne
2024-02-18  3:51       ` Hsia-Jun Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240210180414.49184-1-randy.li@synaptics.com \
    --to=randy.li@synaptics.com \
    --cc=alexious@zju.edu.cn \
    --cc=ayaka@soulik.info \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=nicolas.dufresne@collabora.com \
    --cc=sebastian.fricke@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox