Initialize the fd to -1 for xorg.conf input devices.

Submitted by Peter Hutterer on July 20, 2011, 6 a.m.

Details

Message ID 20110719230018.GA28868@barra.bne.redhat.com
State Deferred, archived
Headers show

Not browsing as part of any series.

Commit Message

Peter Hutterer July 20, 2011, 6 a.m.
For hotplugged devices, xf86AllocateInput does that for us but the xorg.conf
path is different. Since not all drivers reset the fd during PreInit but may
still call close(pInfo->fd) in all cases, this can terminate the logging
early.

Reproducible: add a wacom driver InputDevice section with no Option Device.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
---
I would like to point out that 
http://lists.freedesktop.org/archives/xorg-devel/2011-July/023824.html and
http://lists.freedesktop.org/archives/xorg-devel/2011-July/023765.html are
equally unloved and nonetheless crash the server.

Jeremy: all three are 1.10.x candidates.

 hw/xfree86/common/xf86Config.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

Patch hide | download patch | download mbox

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index ccfad95..7f3316a 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1223,6 +1223,7 @@  checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
 			      (count + 1) * sizeof(InputInfoPtr));
             devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
             Pointer.type_name = XI_MOUSE;
+            Pointer.fd = -1;
 	    *devs[count - 1] = Pointer;
 	    devs[count - 1]->options =
 				xf86addNewOption(devs[count -1]->options,
@@ -1269,6 +1270,7 @@  checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
 			      (count + 1) * sizeof(InputInfoPtr));
             devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
             Pointer.type_name = XI_MOUSE;
+            Pointer.fd = -1;
 	    *devs[count - 1] = Pointer;
 	    devs[count - 1]->options =
 				xf86addNewOption(NULL, xnfstrdup("AlwaysCore"), NULL);
@@ -1366,6 +1368,7 @@  checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
 			      (count + 1) * sizeof(InputInfoPtr));
             devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
             Keyboard.type_name = XI_KEYBOARD;
+            Keyboard.fd = -1;
 	    *devs[count - 1] = Keyboard;
 	    devs[count - 1]->options =
 				xf86addNewOption(devs[count - 1]->options,

Comments

On Wed, Jul 20, 2011 at 09:00:18AM +1000, Peter Hutterer wrote:
> For hotplugged devices, xf86AllocateInput does that for us but the xorg.conf
> path is different. Since not all drivers reset the fd during PreInit but may
> still call close(pInfo->fd) in all cases, this can terminate the logging
> early.
> 
> Reproducible: add a wacom driver InputDevice section with no Option Device.
> 
> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

Reviewed-by: Daniel Stone <daniel@fooishbar.org>

Cheers,
Daniel