summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErkki Seppälä <erkki.seppala@vincit.fi>2011-03-10 11:40:40 +0200
committerJeremy Huddleston <jeremyhu@apple.com>2011-03-14 15:34:04 -0700
commitdb9321b33047dadc791246c9830abcbd05ef76d1 (patch)
treef89fe6bbdee55dda9f36e78e5e941d40e4244233
parent8ffaef2ebd2611e2eed4ef97350c3a34508f5252 (diff)
xfree86/modes: Fixed memory leak in xf86InitialConfiguration
There were two memory leaks in the function: one was the lack of free for "enabled", the other was the full lack of releasing anything when configuration was too small. The first issue was fixed by adding the missing free, the other was addressed by replacing the duplicate memory releasing sequences with one that is gotoed into. Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Rami Ylimäki <rami.ylimaki@vincit.fi> Signed-off-by: Erkki Seppälä <erkki.seppala@vincit.fi> Signed-off-by: Keith Packard <keithp@keithp.com> (cherry picked from commit d3adf2d9350bee4125107e2ea1ed0c51bb736562)
-rw-r--r--hw/xfree86/modes/xf86Crtc.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 30742ff2e..4db4d22d6 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -2355,6 +2355,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
int i = scrn->scrnIndex;
Bool have_outputs = TRUE;
Bool ret;
+ Bool success = FALSE;
/* Set up the device options */
config->options = xnfalloc (sizeof (xf86DeviceOptions));
@@ -2413,11 +2414,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
* Set the position of each output
*/
if (!xf86InitialOutputPositions (scrn, modes))
- {
- free(crtcs);
- free(modes);
- return FALSE;
- }
+ goto bailout;
/*
* Set initial panning of each output
@@ -2428,11 +2425,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
* Assign CRTCs to fit output configuration
*/
if (have_outputs && !xf86PickCrtcs (scrn, crtcs, modes, 0, width, height))
- {
- free(crtcs);
- free(modes);
- return FALSE;
- }
+ goto bailout;
/* XXX override xf86 common frame computation code */
@@ -2509,7 +2502,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
* Make sure the configuration isn't too small.
*/
if (width < config->minWidth || height < config->minHeight)
- return FALSE;
+ goto bailout;
/*
* Limit the crtc config to virtual[XY] if the driver can't grow the
@@ -2532,10 +2525,12 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
xf86CVTMode(width, height, 60, 0, 0));
}
-
+ success = TRUE;
+ bailout:
free(crtcs);
free(modes);
- return TRUE;
+ free(enabled);
+ return success;
}
/*