diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-02-04 10:11:13 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-02-05 14:31:29 +1000 |
commit | 0e15697b53c9448ce9911aa6499b2ea0bda92af6 (patch) | |
tree | 5169025e031c6000d3feaac8b48f7b7ed393000d | |
parent | db836715198a445dc3b32c3df0610f700930483f (diff) |
dix: die if we can't activate or init the VCP/VCK.
If we have a busted xkb setup, the XKB initialization on the core devices
fails and leaves us with dev->key->xkbInfo == NULL. This in turn causes
segfaults lateron.
Return BadValue when the XKB configuration for a master device failed, and if
that happens for the VCP/VCK, die semi-gracefully.
The VCP init can only fail on OOM.
Reported by Aaron Plattner.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Dan Nicholson <dbn.lists@gmail.com>
Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
-rw-r--r-- | dix/devices.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/dix/devices.c b/dix/devices.c index 4f85c6d7c..934e6952f 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -488,8 +488,13 @@ CoreKeyboardProc(DeviceIntPtr pDev, int what) switch (what) { case DEVICE_INIT: XkbGetRulesDflts(&rmlvo); - InitKeyboardDeviceStruct(pDev, &rmlvo, CoreKeyboardBell, - CoreKeyboardCtl); + if (!InitKeyboardDeviceStruct(pDev, &rmlvo, CoreKeyboardBell, + CoreKeyboardCtl)) + { + ErrorF("Keyboard initialization failed. This could be a missing " + "or incorrect setup of xkeyboard-config.\n"); + return BadValue; + } return Success; case DEVICE_ON: @@ -519,9 +524,14 @@ CorePointerProc(DeviceIntPtr pDev, int what) case DEVICE_INIT: for (i = 1; i <= 32; i++) map[i] = i; - InitPointerDeviceStruct((DevicePtr)pDev, map, 32, + if (!InitPointerDeviceStruct((DevicePtr)pDev, map, 32, (PtrCtrlProcPtr)NoopDDA, - GetMotionHistorySize(), 2); + GetMotionHistorySize(), 2)) + { + ErrorF("Could not initialize device '%s'. Out of memory.\n", + pDev->name); + return BadAlloc; /* IPDS only fails on allocs */ + } pDev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2; pDev->last.valuators[0] = pDev->valuator->axisVal[0]; pDev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2; @@ -554,11 +564,12 @@ InitCoreDevices(void) &inputInfo.keyboard) != Success) FatalError("Failed to allocate core devices"); - ActivateDevice(inputInfo.pointer); - ActivateDevice(inputInfo.keyboard); - EnableDevice(inputInfo.pointer); - EnableDevice(inputInfo.keyboard); - + if (ActivateDevice(inputInfo.pointer) != Success || + ActivateDevice(inputInfo.keyboard) != Success) + FatalError("Failed to activate core devices."); + if (!EnableDevice(inputInfo.pointer) || + !EnableDevice(inputInfo.keyboard)) + FatalError("Failed to enable core devices."); } /** |