media: cedrus: Forbid setting new formats on busy queues
authorPaul Kocialkowski <paul.kocialkowski@bootlin.com>
Thu, 14 Feb 2019 09:25:11 +0000 (04:25 -0500)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 18 Feb 2019 20:33:02 +0000 (15:33 -0500)
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.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/staging/media/sunxi/cedrus/cedrus_video.c

index b5cc79389d672c0e484001a5c8b6f27891246291..b47854b3bce46f10ba0e828a8e7cac2b80855013 100644 (file)
@@ -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;