Module Name: xsrc
Committed By: christos
Date: Fri Oct 7 16:01:50 UTC 2016
Modified Files:
xsrc/external/mit/xorg-server/dist/hw/xfree86/drivers/modesetting:
driver.c
Log Message:
CID 1373520: Fix memory leak, don't allocate needlessly.
CID 1373521: Fix memory leak.
To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \
xsrc/external/mit/xorg-server/dist/hw/xfree86/drivers/modesetting/driver.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: xsrc/external/mit/xorg-server/dist/hw/xfree86/drivers/modesetting/driver.c
diff -u xsrc/external/mit/xorg-server/dist/hw/xfree86/drivers/modesetting/driver.c:1.1.1.1 xsrc/external/mit/xorg-server/dist/hw/xfree86/drivers/modesetting/driver.c:1.2
--- xsrc/external/mit/xorg-server/dist/hw/xfree86/drivers/modesetting/driver.c:1.1.1.1 Wed Aug 10 03:44:34 2016
+++ xsrc/external/mit/xorg-server/dist/hw/xfree86/drivers/modesetting/driver.c Fri Oct 7 12:01:50 2016
@@ -752,8 +752,8 @@ ms_get_drm_master_fd(ScrnInfoPtr pScrn)
if (pEnt->location.type == BUS_PCI) {
ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index);
if (ms->PciInfo) {
- BusID = malloc(64);
- sprintf(BusID, "PCI:%d:%d:%d",
+ char BusID[256];
+ snprintf(BusID, sizeof(BusID), "PCI:%d:%d:%d",
#if XSERVER_LIBPCIACCESS
((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
ms->PciInfo->dev, ms->PciInfo->func
@@ -796,12 +796,15 @@ PreInit(ScrnInfoPtr pScrn, int flags)
pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
if (flags & PROBE_DETECT) {
+ free(pEnt);
return FALSE;
}
/* Allocate driverPrivate */
- if (!GetRec(pScrn))
+ if (!GetRec(pScrn)) {
+ free(pEnt);
return FALSE;
+ }
ms = modesettingPTR(pScrn);
ms->SaveGeneration = -1;