]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
media: verisilicon: Free post processor buffers on error
authorDetlev Casanova <detlev.casanova@collabora.com>
Fri, 25 Apr 2025 19:24:47 +0000 (15:24 -0400)
committerHans Verkuil <hverkuil@xs4all.nl>
Thu, 15 May 2025 06:13:31 +0000 (08:13 +0200)
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 <detlev.casanova@collabora.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/platform/verisilicon/hantro_postproc.c

index c435a393e0cb70de9ecea729758c81a7fd367c68..9f559a13d409bb8e6fa916ad15a7553cee26cc95 100644 (file)
@@ -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;