diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-07-29 21:55:29 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-07-29 21:55:29 +0100 |
commit | d7465ece29c9ae665a5a9f5bdac764a19062786e (patch) | |
tree | 347e65df8f77361238931b54f471ac737d660c6c /src | |
parent | 5751b9f1f5beb943db8cb5d260379ae39eb18db4 (diff) | |
download | xorg-driver-xf86-video-intel-d7465ece29c9ae665a5a9f5bdac764a19062786e.tar.gz |
sna: Cleanup along all error paths in sna_pre_init()
Only one out of a dozen error paths actually freed the locally allocated
memory, oops.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/sna/sna_driver.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c index 9c338bb0..16dbc91b 100644 --- a/src/sna/sna_driver.c +++ b/src/sna/sna_driver.c @@ -276,15 +276,6 @@ cleanup_front: return FALSE; } -static void PreInitCleanup(ScrnInfoPtr scrn) -{ - if (!scrn || !scrn->driverPrivate) - return; - - free(scrn->driverPrivate); - scrn->driverPrivate = NULL; -} - static void sna_selftest(void) { sna_damage_selftest(); @@ -434,7 +425,7 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags) if (fd == -1) { xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to become DRM master.\n"); - return FALSE; + goto cleanup; } preferred_depth = sna->info->gen < 030 ? 15 : 24; @@ -444,7 +435,7 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags) if (!xf86SetDepthBpp(scrn, preferred_depth, 0, 0, Support32bppFb | SupportConvert24to32 | PreferConvert24to32)) - return FALSE; + goto cleanup; switch (scrn->depth) { case 8: @@ -458,18 +449,18 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags) xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Given depth (%d) is not supported by the Intel driver and this chipset.\n", scrn->depth); - return FALSE; + goto cleanup; } xf86PrintDepthBpp(scrn); if (!xf86SetWeight(scrn, defaultWeight, defaultWeight)) - return FALSE; + goto cleanup; if (!xf86SetDefaultVisual(scrn, -1)) - return FALSE; + goto cleanup; sna->Options = intel_options_get(scrn); if (sna->Options == NULL) - return FALSE; + goto cleanup; sna_setup_capabilities(scrn, fd); @@ -523,8 +514,7 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags) if (!sna_mode_pre_init(scrn, sna)) { xf86DrvMsg(scrn->scrnIndex, X_ERROR, "No outputs and no modes.\n"); - PreInitCleanup(scrn); - return FALSE; + goto cleanup; } scrn->currentMode = scrn->modes; @@ -536,6 +526,11 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags) sna->dri_available = !!xf86LoadSubModule(scrn, "dri2"); return TRUE; + +cleanup: + scrn->driverPrivate = (void *)((uintptr_t)sna->info | 1); + free(sna); + return FALSE; } static void |