loader: Handle mod->VersionInfo == NULL

This can happen when a module fails to load:

Program received signal SIGSEGV, Segmentation fault.
UnloadModule (_mod=0x5555559d9280) at ../../../../hw/xfree86/loader/loadmod.c:848
848	    name = mod->VersionInfo->modname;
(gdb) bt
#0  UnloadModule (_mod=0x5555559d9280) at ../../../../hw/xfree86/loader/loadmod.c:848
#1  0x00005555555ddd1b in LoadModule (module=module@entry=0x5555559c7ce0 "fbdev", options=0x0, modreq=modreq@entry=0x0, errmaj=errmaj@entry=0x7fffffffe8ec) at ../../../../hw/xfree86/loader/loadmod.c:824
#2  0x00005555555edfe9 in xf86LoadModules (list=list@entry=0x5555559dcf50, optlist=optlist@entry=0x0) at ../../../../hw/xfree86/common/xf86Init.c:1506
#3  0x00005555555ee7bc in InitOutput (pScreenInfo=pScreenInfo@entry=0x5555559abf80 <screenInfo>, argc=argc@entry=4, argv=argv@entry=0x7fffffffeb18) at ../../../../hw/xfree86/common/xf86Init.c:484
#4  0x00005555555a885c in dix_main (argc=4, argv=0x7fffffffeb18, envp=<optimized out>) at ../../dix/main.c:197
#5  0x00007ffff5d582b1 in __libc_start_main (main=0x555555593130 <main>, argc=4, argv=0x7fffffffeb18, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffeb08) at ../csu/libc-start.c:291
#6  0x000055555559316a in _start ()

Fixes: 8e83eacb9e ("loader: Remove unused path and name from ModuleDescPtr")
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Michel Dänzer 2017-01-26 16:24:03 +09:00 committed by Peter Hutterer
parent 7617a0a180
commit 45e0eb4b15

View File

@ -837,7 +837,6 @@ void
UnloadModule(void *_mod)
{
ModuleDescPtr mod = _mod;
const char *name;
if (mod == (ModuleDescPtr) 1)
return;
@ -845,17 +844,19 @@ UnloadModule(void *_mod)
if (mod == NULL)
return;
name = mod->VersionInfo->modname;
if (mod->VersionInfo) {
const char *name = mod->VersionInfo->modname;
if (mod->parent)
LogMessageVerbSigSafe(X_INFO, 3, "UnloadSubModule: \"%s\"\n", name);
else
LogMessageVerbSigSafe(X_INFO, 3, "UnloadModule: \"%s\"\n", name);
if (mod->parent)
LogMessageVerbSigSafe(X_INFO, 3, "UnloadSubModule: \"%s\"\n", name);
else
LogMessageVerbSigSafe(X_INFO, 3, "UnloadModule: \"%s\"\n", name);
if (mod->TearDownData != ModuleDuplicated) {
if ((mod->TearDownProc) && (mod->TearDownData))
mod->TearDownProc(mod->TearDownData);
LoaderUnload(name, mod->handle);
if (mod->TearDownData != ModuleDuplicated) {
if ((mod->TearDownProc) && (mod->TearDownData))
mod->TearDownProc(mod->TearDownData);
LoaderUnload(name, mod->handle);
}
}
if (mod->child)