xfree86: Remove device from inputInfo.devices if ActivateDevice failed.

After the call to xf86ActivateDevice, the new device will be added to
inputInfo.devices. However, if the subsequent call to ActivateDevice
fails, the correponding InputInfoRec for the device is deleted but an
entry still remains in inputInfo.devices. This might lead to a server
crash later on (on InitAndStartDevices for instance) when the device
control proc would be called for an invalid device.
(cherry picked from commit efa31092d6)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Ander Conselvan de Oliveira 2009-04-06 16:01:20 -03:00 committed by Keith Packard
parent 24dc7694a2
commit 0df12a3f01

View File

@ -543,7 +543,11 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
dev = pInfo->dev; dev = pInfo->dev;
rval = ActivateDevice(dev); rval = ActivateDevice(dev);
if (rval != Success) if (rval != Success)
{
xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", idev->identifier);
RemoveDevice(dev);
goto unwind; goto unwind;
}
/* Enable it if it's properly initialised and we're currently in the VT */ /* Enable it if it's properly initialised and we're currently in the VT */
if (enable && dev->inited && dev->startup && xf86Screens[0]->vtSema) if (enable && dev->inited && dev->startup && xf86Screens[0]->vtSema)