[PATCH] media: mediatek: vcodec: free working buf on error path in vdec_vp9_slice_setup_lat()

Nicolas Dufresne nicolas at ndufresne.ca
Tue Apr 28 13:35:20 PDT 2026


Le lundi 30 mars 2026 à 10:02 +0800, Haoxiang Li a écrit :
> Add an error path label in vdec_vp9_slice_setup_lat()
> and call vdec_vp9_slice_free_working_buffer() to free
> working buffer to prevent potential memory leak.
> 
> Fixes: 5d418351ca8f ("media: mediatek: vcodec: support stateless VP9 decoding")
> Cc: stable at vger.kernel.org
> Signed-off-by: Haoxiang Li <lihaoxiang at isrc.iscas.ac.cn>
> ---
>  .../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c    | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
> index cd1935014d76..3dadb5cc8876 100644
> --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
> +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c
> @@ -1168,7 +1168,7 @@ static int vdec_vp9_slice_setup_lat(struct vdec_vp9_slice_instance *instance,
>  
>  	ret = vdec_vp9_slice_setup_lat_buffer(instance, vsi, bs, lat_buf);

This function never fails, please remove its return value and remove the error
code below instead.

>  	if (ret)
> -		goto err;
> +		goto alloc_err;
>  
>  	vdec_vp9_slice_setup_seg_buffer(instance, vsi, &instance->seg[0]);
>  
> @@ -1176,14 +1176,16 @@ static int vdec_vp9_slice_setup_lat(struct vdec_vp9_slice_instance *instance,
>  
>  	ret = vdec_vp9_slice_setup_prob_buffer(instance, vsi);

Same issue, that function should not have had a return value.

>  	if (ret)
> -		goto err;
> +		goto alloc_err;
>  
>  	ret = vdec_vp9_slice_setup_tile_buffer(instance, vsi, bs);
>  	if (ret)
> -		goto err;
> +		goto alloc_err;

Ack for this one.

>  
>  	return 0;
>  
> +alloc_err:
> +	vdec_vp9_slice_free_working_buffer(instance);
>  err:
>  	return ret;
>  }


cheers,
Nicolas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-mediatek/attachments/20260428/63aeb14b/attachment.sig>


More information about the Linux-mediatek mailing list