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

Nicolas Dufresne nicolas at ndufresne.ca
Wed Jul 15 14:46:17 PDT 2026


Hi,

Le mercredi 15 juillet 2026 à 17:35 -0400, Nicolas Dufresne a écrit :
> Le mercredi 06 mai 2026 à 16:42 +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>
> 
> Reviewed-by: Nicolas Dufresne <nicolas.dufresne at collabora.com>

After consideration, I will drop path 3 and 4. The working buffer is
implementing a re-alloc scheme. Even when the alloc fails, some buffer remains,
which you didn't cleanup. In the end, its not very useful to clean them up as
closing the driver FD will do that (calling IF deinit). I'll pick the two first,
as its fair cleanup.

Nicolas

> 
> > ---
> >  .../mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c        | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > 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 0f47b2671353..673b17d0dd8d 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
> > @@ -1172,10 +1172,12 @@ static int vdec_vp9_slice_setup_lat(struct
> > vdec_vp9_slice_instance *instance,
> >  
> >  	ret = vdec_vp9_slice_setup_tile_buffer(instance, vsi, bs);
> >  	if (ret)
> > -		goto err;
> > +		goto alloc_err;
> >  
> >  	return 0;
> >  
> > +alloc_err:
> > +	vdec_vp9_slice_free_working_buffer(instance);
> >  err:
> >  	return ret;
> >  }
-------------- 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/20260715/4269f227/attachment.sig>


More information about the Linux-mediatek mailing list