163 lines
4.6 KiB
Diff
163 lines
4.6 KiB
Diff
From 4ec3d67da829f4e7a35ab08427002b9d7e4e5f4b Mon Sep 17 00:00:00 2001
|
|
From: Thomas Hellstrom <thellstrom@vmware.com>
|
|
Date: Tue, 27 Nov 2018 16:20:32 +0100
|
|
Subject: [PATCH 02/11] vmwgfx: Fix XVideo memory leaks
|
|
|
|
We were not properly freeing the port privates.
|
|
In order to access those at CloseScreen time, don't free the adaptor pointers
|
|
at XV screen init, but hold on to them until CloseScreen.
|
|
|
|
Also properly free the new_adaptors pointer.
|
|
|
|
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
|
|
Reviewed-by: Brian Paul <brianp@vmware.com>
|
|
---
|
|
vmwgfx/vmwgfx_driver.c | 2 ++
|
|
vmwgfx/vmwgfx_driver.h | 9 +++++++-
|
|
vmwgfx/vmwgfx_overlay.c | 11 ++++------
|
|
vmwgfx/vmwgfx_tex_video.c | 44 ++++++++++++++++++++++++++-------------
|
|
4 files changed, 44 insertions(+), 22 deletions(-)
|
|
|
|
diff --git a/vmwgfx/vmwgfx_driver.c b/vmwgfx/vmwgfx_driver.c
|
|
index 665f620..ccddb6f 100644
|
|
--- a/vmwgfx/vmwgfx_driver.c
|
|
+++ b/vmwgfx/vmwgfx_driver.c
|
|
@@ -1327,6 +1327,8 @@ drv_close_screen(CLOSE_SCREEN_ARGS_DECL)
|
|
pScrn->LeaveVT(VT_FUNC_ARGS);
|
|
|
|
vmwgfx_uevent_fini(pScrn, ms);
|
|
+ vmw_xv_close(pScreen);
|
|
+
|
|
pScrn->vtSema = FALSE;
|
|
|
|
vmwgfx_unwrap(ms, pScrn, EnterVT);
|
|
diff --git a/vmwgfx/vmwgfx_driver.h b/vmwgfx/vmwgfx_driver.h
|
|
index 05abebe..cfd2ed2 100644
|
|
--- a/vmwgfx/vmwgfx_driver.h
|
|
+++ b/vmwgfx/vmwgfx_driver.h
|
|
@@ -157,6 +157,11 @@ typedef struct _modesettingRec
|
|
Bool xa_dri3;
|
|
Bool dri3_available;
|
|
#endif
|
|
+
|
|
+ /* Video */
|
|
+ XF86VideoAdaptorPtr overlay;
|
|
+ XF86VideoAdaptorPtr textured;
|
|
+
|
|
} modesettingRec, *modesettingPtr;
|
|
|
|
#define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate))
|
|
@@ -231,7 +236,9 @@ xorg_xv_init(ScreenPtr pScreen);
|
|
XF86VideoAdaptorPtr
|
|
vmw_video_init_adaptor(ScrnInfoPtr pScrn);
|
|
void
|
|
-vmw_video_free_adaptor(XF86VideoAdaptorPtr adaptor, Bool free_ports);
|
|
+vmw_video_free_adaptor(XF86VideoAdaptorPtr adaptor);
|
|
+void
|
|
+vmw_xv_close(ScreenPtr pScreen);
|
|
|
|
void
|
|
vmw_ctrl_ext_init(ScrnInfoPtr pScrn);
|
|
diff --git a/vmwgfx/vmwgfx_overlay.c b/vmwgfx/vmwgfx_overlay.c
|
|
index c35cebd..94d738c 100644
|
|
--- a/vmwgfx/vmwgfx_overlay.c
|
|
+++ b/vmwgfx/vmwgfx_overlay.c
|
|
@@ -258,15 +258,12 @@ vmwgfx_overlay_port_create(int drm_fd, ScreenPtr pScreen)
|
|
}
|
|
|
|
void
|
|
-vmw_video_free_adaptor(XF86VideoAdaptorPtr adaptor, Bool free_ports)
|
|
+vmw_video_free_adaptor(XF86VideoAdaptorPtr adaptor)
|
|
{
|
|
- if (free_ports) {
|
|
- int i;
|
|
+ int i;
|
|
|
|
- for(i=0; i<adaptor->nPorts; ++i) {
|
|
- free(adaptor->pPortPrivates[i].ptr);
|
|
- }
|
|
- }
|
|
+ for (i = 0; i < adaptor->nPorts; ++i)
|
|
+ free(adaptor->pPortPrivates[i].ptr);
|
|
|
|
free(adaptor->pPortPrivates);
|
|
xf86XVFreeVideoAdaptorRec(adaptor);
|
|
diff --git a/vmwgfx/vmwgfx_tex_video.c b/vmwgfx/vmwgfx_tex_video.c
|
|
index e42a4c6..acc2b56 100644
|
|
--- a/vmwgfx/vmwgfx_tex_video.c
|
|
+++ b/vmwgfx/vmwgfx_tex_video.c
|
|
@@ -904,15 +904,12 @@ port_priv_create(struct xa_tracker *xat, struct xa_context *r,
|
|
}
|
|
|
|
static void
|
|
-vmwgfx_free_textured_adaptor(XF86VideoAdaptorPtr adaptor, Bool free_ports)
|
|
+vmwgfx_free_textured_adaptor(XF86VideoAdaptorPtr adaptor)
|
|
{
|
|
- if (free_ports) {
|
|
- int i;
|
|
+ int i;
|
|
|
|
- for(i=0; i<adaptor->nPorts; ++i) {
|
|
- free(adaptor->pPortPrivates[i].ptr);
|
|
- }
|
|
- }
|
|
+ for (i = 0; i < adaptor->nPorts; ++i)
|
|
+ free(adaptor->pPortPrivates[i].ptr);
|
|
|
|
free(adaptor->pAttributes);
|
|
free(adaptor->pPortPrivates);
|
|
@@ -986,6 +983,23 @@ xorg_setup_textured_adapter(ScreenPtr pScreen)
|
|
return adapt;
|
|
}
|
|
|
|
+void
|
|
+vmw_xv_close(ScreenPtr pScreen)
|
|
+{
|
|
+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
|
|
+ modesettingPtr ms = modesettingPTR(pScrn);
|
|
+
|
|
+ if (ms->overlay) {
|
|
+ vmw_video_free_adaptor(ms->overlay);
|
|
+ ms->overlay = NULL;
|
|
+ }
|
|
+
|
|
+ if (ms->textured) {
|
|
+ vmwgfx_free_textured_adaptor(ms->textured);
|
|
+ ms->textured = NULL;
|
|
+ }
|
|
+}
|
|
+
|
|
void
|
|
xorg_xv_init(ScreenPtr pScreen)
|
|
{
|
|
@@ -1025,17 +1039,19 @@ xorg_xv_init(ScreenPtr pScreen)
|
|
adaptors[num_adaptors++] = overlay_adaptor;
|
|
|
|
if (num_adaptors) {
|
|
- Bool ret;
|
|
- ret = xf86XVScreenInit(pScreen, adaptors, num_adaptors);
|
|
- if (textured_adapter)
|
|
- vmwgfx_free_textured_adaptor(textured_adapter, !ret);
|
|
- if (overlay_adaptor)
|
|
- vmw_video_free_adaptor(overlay_adaptor, !ret);
|
|
- if (!ret)
|
|
+ if (xf86XVScreenInit(pScreen, adaptors, num_adaptors)) {
|
|
+ ms->overlay = overlay_adaptor;
|
|
+ ms->textured = textured_adapter;
|
|
+ } else {
|
|
+ ms->overlay = NULL;
|
|
+ ms->textured = NULL;
|
|
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
|
|
"Failed to initialize Xv.\n");
|
|
+ }
|
|
} else {
|
|
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
|
|
"Disabling Xv because no adaptors could be initialized.\n");
|
|
}
|
|
+
|
|
+ free(new_adaptors);
|
|
}
|
|
--
|
|
2.23.0
|
|
|