[PATCH xserver] glamor: glamor_egl_get_display: Return NULL if eglGetPlatformDisplayEXT returns NULL

2016-12-20 Thread Hans de Goede
If the libEGL we are using has eglGetPlatformDisplayEXT, yet it still
returns NULL, then this very likely means that it does not support
the type (e.g. EGL_PLATFORM_GBM_MESA) passed in, and then returning NULL
is the right thing to do.

This avoids falling back to an eglGetDisplay() implementation which does
not understands the passed in gbm handle, treats it as a pointer to
something else completely, followed by a crash sooner or later.

Specifically this fixes using the nvidia binary driver, with nvidia's
libEGL + the modesetting driver on a secondary GPU crashing inside
glamor_egl_init() sometimes.

Cc: Adam Jackson 
Cc: Eric Anholt 
Signed-off-by: Hans de Goede 
---
 glamor/glamor_egl.c | 4 
 glamor/glamor_egl.h | 4 +---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 9cc0f8d..4bde637 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -769,6 +769,10 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
 
 glamor_egl->display = glamor_egl_get_display(EGL_PLATFORM_GBM_MESA,
  glamor_egl->gbm);
+if (!glamor_egl->display) {
+xf86DrvMsg(scrn->scrnIndex, X_ERROR, "eglGetDisplay() failed\n");
+goto error;
+}
 #else
 glamor_egl->display = eglGetDisplay((EGLNativeDisplayType) (intptr_t) fd);
 #endif
diff --git a/glamor/glamor_egl.h b/glamor/glamor_egl.h
index 6b05f57..2c6d307 100644
--- a/glamor/glamor_egl.h
+++ b/glamor/glamor_egl.h
@@ -67,9 +67,7 @@ glamor_egl_get_display(EGLint type, void *native)
 PFNEGLGETPLATFORMDISPLAYEXTPROC getPlatformDisplayEXT =
 (void *) eglGetProcAddress("eglGetPlatformDisplayEXT");
 if (getPlatformDisplayEXT)
-dpy = getPlatformDisplayEXT(type, native, NULL);
-if (dpy)
-return dpy;
+return getPlatformDisplayEXT(type, native, NULL);
 }
 
 /* Welp, everything is awful. */
-- 
2.9.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xf86-input-libinput] Ignore LED updates for disabled devices

2016-12-20 Thread Hans de Goede

Hi,

On 20-12-16 11:09, Peter Hutterer wrote:

If an XKB AccessX timeout is set and a VT switch is triggered, the
AccessXTimeoutExpire function may be called after the device has already been
disabled. This can cause a null-pointer dereference as our shared libinput
device may have been released by then.

In the legacy drivers this would've simply caused a write to an invalid fd
(-1), not a crash. Here we need to be more careful.

https://bugs.freedesktop.org/show_bug.cgi?id=98464

Signed-off-by: Peter Hutterer 


Patch LGTM:

Reviewed-by: Hans de Goede 

Regards,

Hans




---
 src/xf86libinput.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index b130a77..fd38c3b 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -785,6 +785,9 @@ xf86libinput_kbd_ctrl(DeviceIntPtr device, KeybdCtrl *ctrl)
 struct xf86libinput *driver_data = pInfo->private;
 struct libinput_device *ldevice = driver_data->shared_device->device;

+if (!device->enabled)
+   return;
+
 while (bits[i].xbit) {
if (ctrl->leds & bits[i].xbit)
leds |= bits[i].code;


___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xf86-input-libinput] Ignore LED updates for disabled devices

2016-12-20 Thread Peter Hutterer
If an XKB AccessX timeout is set and a VT switch is triggered, the
AccessXTimeoutExpire function may be called after the device has already been
disabled. This can cause a null-pointer dereference as our shared libinput
device may have been released by then.

In the legacy drivers this would've simply caused a write to an invalid fd
(-1), not a crash. Here we need to be more careful.

https://bugs.freedesktop.org/show_bug.cgi?id=98464

Signed-off-by: Peter Hutterer 
---
 src/xf86libinput.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index b130a77..fd38c3b 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -785,6 +785,9 @@ xf86libinput_kbd_ctrl(DeviceIntPtr device, KeybdCtrl *ctrl)
 struct xf86libinput *driver_data = pInfo->private;
 struct libinput_device *ldevice = driver_data->shared_device->device;
 
+if (!device->enabled)
+   return;
+
 while (bits[i].xbit) {
if (ctrl->leds & bits[i].xbit)
leds |= bits[i].code;
-- 
2.9.3

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel