summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2017-10-19 17:41:44 +0200
committerMichel Dänzer <michel@daenzer.net>2017-10-20 10:35:20 +0200
commitcfccf4c4e7e5c73fe4040fabeb1b43283cf29b33 (patch)
tree526fd44b261be9a6753aa6e128865d84a51658e8
parent9d84934309e4ccd9a43c73d958b8ff10ef2fc990 (diff)
Free memory returned by xf86GetEntityInfo
We were leaking it. Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--src/amdgpu_kms.c19
-rw-r--r--src/amdgpu_probe.c6
2 files changed, 17 insertions, 8 deletions
diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index 44a99b5..7d58209 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -116,16 +116,24 @@ static void AMDGPUFreeRec(ScrnInfoPtr pScrn)
DevUnion *pPriv;
AMDGPUEntPtr pAMDGPUEnt;
AMDGPUInfoPtr info;
+ EntityInfoPtr pEnt;
if (!pScrn)
return;
info = AMDGPUPTR(pScrn);
- if (info && info->fbcon_pixmap)
- pScrn->pScreen->DestroyPixmap(info->fbcon_pixmap);
+ if (info) {
+ if (info->fbcon_pixmap)
+ pScrn->pScreen->DestroyPixmap(info->fbcon_pixmap);
- pPriv = xf86GetEntityPrivate(xf86GetEntityInfo(pScrn->entityList[pScrn->numEntities - 1])->index,
- gAMDGPUEntityIndex);
+ pEnt = info->pEnt;
+ free(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+ } else {
+ pEnt = xf86GetEntityInfo(pScrn->entityList[pScrn->numEntities - 1]);
+ }
+
+ pPriv = xf86GetEntityPrivate(pEnt->index, gAMDGPUEntityIndex);
pAMDGPUEnt = pPriv->ptr;
if (pAMDGPUEnt->fd > 0) {
DevUnion *pPriv;
@@ -143,8 +151,7 @@ static void AMDGPUFreeRec(ScrnInfoPtr pScrn)
}
}
- free(pScrn->driverPrivate);
- pScrn->driverPrivate = NULL;
+ free(pEnt);
}
static void *amdgpuShadowWindow(ScreenPtr screen, CARD32 row, CARD32 offset,
diff --git a/src/amdgpu_probe.c b/src/amdgpu_probe.c
index e446539..0217060 100644
--- a/src/amdgpu_probe.c
+++ b/src/amdgpu_probe.c
@@ -177,7 +177,7 @@ static Bool amdgpu_get_scrninfo(int entity_num, struct pci_device *pci_dev)
{
ScrnInfoPtr pScrn = NULL;
char *busid;
- EntityInfoPtr pEnt;
+ EntityInfoPtr pEnt = NULL;
DevUnion *pPriv;
AMDGPUEntPtr pAMDGPUEnt;
@@ -256,6 +256,7 @@ static Bool amdgpu_get_scrninfo(int entity_num, struct pci_device *pci_dev)
error_amdgpu:
amdgpu_kernel_close_fd(pAMDGPUEnt);
error:
+ free(pEnt);
free(busid);
return FALSE;
}
@@ -294,7 +295,7 @@ amdgpu_platform_probe(DriverPtr pDriver,
ScrnInfoPtr pScrn;
int scr_flags = 0;
char *busid;
- EntityInfoPtr pEnt;
+ EntityInfoPtr pEnt = NULL;
DevUnion *pPriv;
AMDGPUEntPtr pAMDGPUEnt;
@@ -379,6 +380,7 @@ amdgpu_platform_probe(DriverPtr pDriver,
error_amdgpu:
amdgpu_kernel_close_fd(pAMDGPUEnt);
error:
+ free(pEnt);
free(busid);
return FALSE;
}