summaryrefslogtreecommitdiff
path: root/hw/xfree86/common
diff options
context:
space:
mode:
authorBen Crocker <bcrocker@redhat.com>2016-11-15 16:34:38 -0500
committerAdam Jackson <ajax@redhat.com>2017-01-11 15:00:58 -0500
commit8cf47472bff1d5ca3de6ff83a80f0d2820c3fb93 (patch)
treec214c4e830b7c3b535446fa33c3fb89745351369 /hw/xfree86/common
parent06a3e7ef3bf9a907f1fba84a3601870a5697f657 (diff)
Fix a segfault that occurs if xorg.conf.d is absent:
In InitOutput, if xf86HandleConfigFile returns CONFIG_NOFILE (which it does if no config file or directory is present), the autoconfig flag is set, causing xf86AutoConfig to be called later on. xf86AutoConfig calls xf86OutputClassDriverList via the call tree: xf86AutoConfig => listPossibleVideoDrivers => xf86PlatformMatchDriver => xf86OutputClassDriverList and xf86OutputClassDriverList attempts to traverse a linked list that is a member of the XF86ConfigRec struct pointed to by the global xf86configptr, which is NULL at this point because the XF86ConfigRec struct is only allocated (by xf86readConfigFile) AFTER the config file and directory have been successfully opened; the CONFIG_NOFILE return from xf86HandleConfigFile occurs BEFORE the call to xf86readConfigFile which allocates the XF86ConfigRec struct. Rx: In read.c (for symmetry with xf86freeConfig, which already appears in this file), add a new function xf86allocateConfig which tests the value of xf86configptr and, if it's NULL, allocates the XF86ConfigRec struct and deposits the pointer in xf86configptr. In xf86Parser.h, add a prototype for the new xf86allocateConfig function. Back in read.c, #include "xf86Config.h". In xf86readConfigFile, change the open-code call to calloc to a call to the new xf86allocateConfig function. In xf86AutoConfig.c, add a call to the new xf86allocateConfig function to the beginning of xf86AutoConfig to make sure the XF86ConfigRec struct is allocated. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Ben Crocker <bcrocker@redhat.com> (cherry picked from commit 8b335d9068fe4e1f1423a4d86c22b69ffcb819a5)
Diffstat (limited to 'hw/xfree86/common')
-rw-r--r--hw/xfree86/common/xf86AutoConfig.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
index 940265144..c3e17beb7 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -149,6 +149,15 @@ xf86AutoConfig(void)
char buf[1024];
ConfigStatus ret;
+ /* Make sure config rec is there */
+ if (xf86allocateConfig() != NULL) {
+ ret = CONFIG_OK; /* OK so far */
+ }
+ else {
+ xf86Msg(X_ERROR, "Couldn't allocate Config record.\n");
+ return FALSE;
+ }
+
listPossibleVideoDrivers(deviceList, 20);
for (p = deviceList; *p; p++) {