Skip to contentSkip to conversation

media: cedrus: Forbid setting new formats on busy queues

PATCH New Paul Kocialkowski 1 participant 1 message Feb 14, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 media: cedrus: Forbid setting new formats on busy queues

Check that our queues are not busy before setting the format or return EBUSY if that's the case. This ensures that our format can't change once buffers are allocated for the queue.

---
 drivers/staging/media/sunxi/cedrus/cedrus_video.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/staging/media/sunxi/cedrus/cedrus_video.c +10 -0
index b5cc79389d67..b47854b3bce4 100644
@@ -282,8 +282,13 @@ static int cedrus_s_fmt_vid_cap(struct file *file, void *priv,
 {
 	struct cedrus_ctx *ctx = cedrus_file2ctx(file);
 	struct cedrus_dev *dev = ctx->dev;
+	struct vb2_queue *vq;
 	int ret;
 
+	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
+	if (vb2_is_busy(vq))
+		return -EBUSY;
+
 	ret = cedrus_try_fmt_vid_cap(file, priv, f);
 	if (ret)
 		return ret;
@@ -299,8 +304,13 @@ static int cedrus_s_fmt_vid_out(struct file *file, void *priv,
 				struct v4l2_format *f)
 {
 	struct cedrus_ctx *ctx = cedrus_file2ctx(file);
+	struct vb2_queue *vq;
 	int ret;
 
+	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, f->type);
+	if (vb2_is_busy(vq))
+		return -EBUSY;
+
 	ret = cedrus_try_fmt_vid_out(file, priv, f);
 	if (ret)
 		return ret;
Signature · 1 line
2.20.1