[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220620175517.648767-6-jernej.skrabec@gmail.com>
Date: Mon, 20 Jun 2022 19:55:15 +0200
From: Jernej Skrabec <jernej.skrabec@...il.com>
To: mripard@...nel.org, paul.kocialkowski@...tlin.com, wens@...e.org,
samuel@...lland.org
Cc: mchehab@...nel.org, gregkh@...uxfoundation.org,
hverkuil-cisco@...all.nl, linux-media@...r.kernel.org,
linux-staging@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org, linux-sunxi@...ts.linux.dev,
linux-kernel@...r.kernel.org,
Jernej Skrabec <jernej.skrabec@...il.com>
Subject: [PATCH 5/7] 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@...il.com>
---
drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 8 ++++++++
1 file changed, 8 insertions(+)
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;
--
2.36.1
Powered by blists - more mailing lists