media: sti: hva: Remove useless check
authorBenjamin Gaignard <benjamin.gaignard@collabora.com>
Thu, 9 Nov 2023 16:34:30 +0000 (17:34 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Thu, 23 Nov 2023 11:02:47 +0000 (12:02 +0100)
Remove index range test since it is done by vb2_get_buffer().
vb2_get_buffer() can return a NULL pointer so we need the return
value.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@collabora.com>
CC: Jean-Christophe Trotin <jean-christophe.trotin@foss.st.com>
Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/st/sti/hva/hva-v4l2.c

index 3a848ca32a0ef26fec271cf1790bfc16a066bd3a..cfe83e9dc01b206ef66e4e3ee47e276f55ccc263 100644 (file)
@@ -569,14 +569,11 @@ static int hva_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
                struct vb2_buffer *vb2_buf;
 
                vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, buf->type);
-
-               if (buf->index >= vq->num_buffers) {
-                       dev_dbg(dev, "%s buffer index %d out of range (%d)\n",
-                               ctx->name, buf->index, vq->num_buffers);
+               vb2_buf = vb2_get_buffer(vq, buf->index);
+               if (!vb2_buf) {
+                       dev_dbg(dev, "%s buffer index %d not found\n", ctx->name, buf->index);
                        return -EINVAL;
                }
-
-               vb2_buf = vb2_get_buffer(vq, buf->index);
                stream = to_hva_stream(to_vb2_v4l2_buffer(vb2_buf));
                stream->bytesused = buf->bytesused;
        }