summaryrefslogtreecommitdiffstats
path: root/multimedia/ffmpeg/patches/131-avcodec-v4l2_m2m-release-the-DRM-hwcontext-reference.patch
blob: 6411c8d73f96f7ad7668b820a357ca7d2a489d8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Daniel Golle <daniel@makrotopia.org>
Date: Fri, 13 Nov 2026 15:11:35 +0000
Subject: [PATCH] avcodec/v4l2_m2m: release the DRM hwcontext references

v4l2_decode_init() allocates a DRM hwdevice context, and
ff_v4l2_buffer_initialize() a hwframes context for the output and for
the capture queue. Nothing drops them, so every decoder that is opened
with DRM PRIME output leaks all three. Unreference them in
v4l2_m2m_destroy_context(), which runs once the decoder is closed and
the last exported frame is freed. A frame holds its own reference to
the frames context, which in turn holds one to the device.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 libavcodec/v4l2_m2m.c | 3 +++
 1 file changed, 3 insertions(+)

--- a/libavcodec/v4l2_m2m.c
+++ b/libavcodec/v4l2_m2m.c
@@ -253,6 +253,9 @@ static void v4l2_m2m_destroy_context(AVR
     V4L2m2mContext *s = context;
 
     ff_v4l2_context_release(&s->capture);
+    av_buffer_unref(&s->capture.frames_ref);
+    av_buffer_unref(&s->output.frames_ref);
+    av_buffer_unref(&s->device_ref);
     sem_destroy(&s->refsync);
 
     if (s->fd >= 0)