[PATCH v2 4/4] media: verisilicon: Fail the job if the decoder buffer can't be allocated
From: Arun Iyengar via B4 Relay
Date: Thu Dec 03 2026 - 00:35:26 EST
From: Arun Iyengar <aiyengar1990@xxxxxxxxx>
hantro_postproc_get_dec_buf_addr() allocates the decoder buffer of a
CAPTURE buffer on demand and returns 0 if that fails. The codecs then
program address 0 as the decode target.
Get the address when the job starts and fail the job if it is 0.
Fixes: 26711491a807 ("media: verisilicon: Refactor postprocessor to store more buffers")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Arun Iyengar <aiyengar1990@xxxxxxxxx>
---
drivers/media/platform/verisilicon/hantro_drv.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index 573818ecc9d8..986c7c722ad9 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -146,7 +146,8 @@ void hantro_watchdog(struct work_struct *work)
/*
* Fails when the CAPTURE buffer is too small for the format that the controls
- * of the request set; the caller then calls hantro_abort_prepare_run().
+ * of the request set, or when the post-processor's decoder buffer cannot be
+ * allocated; the caller then calls hantro_abort_prepare_run().
*/
int hantro_start_prepare_run(struct hantro_ctx *ctx)
{
@@ -160,6 +161,10 @@ int hantro_start_prepare_run(struct hantro_ctx *ctx)
!hantro_dec_buf_fits(ctx, &hantro_get_dst_buf(ctx)->vb2_buf))
return -EINVAL;
+ if (!ctx->is_encoder &&
+ !hantro_get_dec_buf_addr(ctx, &hantro_get_dst_buf(ctx)->vb2_buf))
+ return -ENOMEM;
+
if (!ctx->is_encoder && !ctx->dev->variant->late_postproc) {
if (hantro_needs_postproc(ctx, ctx->vpu_dst_fmt))
hantro_postproc_enable(ctx);
--
2.55.0