[Xf86-video-armsoc] [PATCH 1/1] Fix leak in OMAPProbe if xf86AllocateScreen() fails
armsoc-bugs at arm.com
armsoc-bugs at arm.com
Mon Feb 3 04:14:59 PST 2014
From: Daniel Kurtz <djkurtz at chromium.org>
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
---
src/armsoc_driver.c | 8 ++++++--
1 file 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;
}
--
1.7.9.5
More information about the Xf86-video-armsoc
mailing list