Commit 0ede8c82 authored by Jernej Skrabec's avatar Jernej Skrabec Committed by Mauro Carvalho Chehab
Browse files

media: cedrus: h265: Add a couple of error checks



Now that we have infrastructure for reporting errors, let's add two
checks, which will make sure slice can be actually decoded.

Signed-off-by: default avatarJernej Skrabec <jernej.skrabec@gmail.com>
Reviewed-by: default avatarEzequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 4af46bcc
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -435,9 +435,17 @@ static int cedrus_h265_setup(struct cedrus_ctx *ctx, struct cedrus_run *run)
	 * instead of start of slice data. Padding is 8 bits at most (one bit set to 1 and
	 * at most seven bits set to 0), so we have to inspect only one byte before slice data.
	 */

	if (slice_params->data_byte_offset == 0)
		return -EOPNOTSUPP;

	padding = (u8 *)vb2_plane_vaddr(&run->src->vb2_buf, 0) +
		slice_params->data_byte_offset - 1;

	/* at least one bit must be set in that byte */
	if (*padding == 0)
		return -EINVAL;

	for (count = 0; count < 8; count++)
		if (*padding & (1 << count))
			break;