diff options
author | Jernej Skrabec <jernej.skrabec@gmail.com> | 2022-06-20 18:55:15 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@kernel.org> | 2022-07-17 11:06:04 +0100 |
commit | 0ede8c820ae0bdf7036127934521c6ea8376fc5f (patch) | |
tree | b33cefee983feab108a181960627371a0aec014c | |
parent | 4af46bcc49152fc8a68a6bc5b5a2ca8a3c6db439 (diff) | |
download | linux-0ede8c820ae0bdf7036127934521c6ea8376fc5f.tar.bz2 |
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: Jernej Skrabec <jernej.skrabec@gmail.com>
Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
-rw-r--r-- | drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c index cfde4ccf6011..99020b9f9ff8 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c @@ -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; |