summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kurtz <djkurtz@chromium.org>2014-01-28 10:45:19 +0100
committerMathias Palmqvist <mathias.palmqvist@arm.com>2014-01-31 15:04:49 +0100
commit0dd0b088aaf578c3419eae13151167345323fd11 (patch)
tree652705262cb5d22191e09bff51dd1f792175bf34
parentfeaef1ff4bd3cef539dbcab6490bd353661d7b6f (diff)
Fix leak in OMAPProbe if xf86AllocateScreen() fails
Fixes the leak of devSections and fd. Note: The previous version of OMAPProbe returned FALSE if *any* xf86AllocateScreen() fails. This version returns TRUE if at least one instance is successfully claimed. It should be ok to only allocate and claim some of the screens that were specified by xorg.conf "Device" sections. TODO: Opening fd with OMAPOpenDRM() and closing it with drmClose() is a mismatch. Better would be to: * open with one of drmOpen*() * open with open() and close with close() * introduce a new OMAPCloseDRM() But, any of these would require a separate patch. BUG=none TEST=builds clean; sanity check ui (cherry picked from commit e4f165c9551f883f2dddec7165e557662786f526) From: https://chromium.googlesource.com/chromiumos/third_party/xf86-video-armsoc Change-Id: I2d41d79eb4e7573f146b585afc9ba7a86508a4b5
-rw-r--r--src/armsoc_driver.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/armsoc_driver.c b/src/armsoc_driver.c
index 96989e4..329e11d 100644
--- a/src/armsoc_driver.c
+++ b/src/armsoc_driver.c
@@ -579,7 +579,7 @@ ARMSOCProbe(DriverPtr drv, int flags)
*/
numDevSections = 1;
} else {
- return FALSE;
+ goto out;
}
}
@@ -655,7 +655,8 @@ ARMSOCProbe(DriverPtr drv, int flags)
if (!pScrn) {
EARLY_ERROR_MSG(
"Cannot allocate a ScrnInfoPtr");
- return FALSE;
+ drmClose(fd);
+ goto free_sections;
}
/* Allocate the driver's Screen-specific, "private"
* data structure and hook it into the ScrnInfoRec's
@@ -716,7 +717,10 @@ ARMSOCProbe(DriverPtr drv, int flags)
drmClose(fd);
}
}
+free_sections:
free(devSections);
+
+out:
return foundScreen;
}