On Fri Apr 25 15:24:47 2025 -0400, Detlev Casanova wrote:
> During initialization, the post processor allocates the same number of
> buffers as the buf queue.
> As the init function is called in streamon(), if an allocation fails,
> streamon will return an error and streamoff() will not be called, keeping
> all post processor buffers allocated.
>
> To avoid that, all post proc buffers are freed in case of an allocation
> error.
>
> Fixes: 26711491a807 ("media: verisilicon: Refactor postprocessor to store
> more buffers")
> Signed-off-by: Detlev Casanova <[email protected]>
> Reviewed-by: Nicolas Dufresne <[email protected]>
> Signed-off-by: Nicolas Dufresne <[email protected]>
> Signed-off-by: Hans Verkuil <[email protected]>
Patch committed.
Thanks,
Hans Verkuil
drivers/media/platform/verisilicon/hantro_postproc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/drivers/media/platform/verisilicon/hantro_postproc.c
b/drivers/media/platform/verisilicon/hantro_postproc.c
index c435a393e0cb..9f559a13d409 100644
--- a/drivers/media/platform/verisilicon/hantro_postproc.c
+++ b/drivers/media/platform/verisilicon/hantro_postproc.c
@@ -250,8 +250,10 @@ int hantro_postproc_init(struct hantro_ctx *ctx)
for (i = 0; i < num_buffers; i++) {
ret = hantro_postproc_alloc(ctx, i);
- if (ret)
+ if (ret) {
+ hantro_postproc_free(ctx);
return ret;
+ }
}
return 0;