xf86-video-intel: 2 commits - tools/virtual.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Sep 2 07:45:44 PDT 2013


 tools/virtual.c |   30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

New commits:
commit 0ee287af222552f4968f7d78ebc748db5bed5963
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Sep 2 15:42:09 2013 +0100

    intel-virtual-overlay: Prevent buffer overrun reading the XEvent
    
    When calling XNextEvent() you must provide it with space for any event,
    i.e. XEvent, and not be tempted to pass in the specific type you are
    waiting for!
    
    Reported-by: Philipp Adolf
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/tools/virtual.c b/tools/virtual.c
index ffac700..ccd8c85 100644
--- a/tools/virtual.c
+++ b/tools/virtual.c
@@ -1901,13 +1901,13 @@ static int first_display_register_as_singleton(struct context *ctx)
 		}
 
 		while (XPending(display->dpy)) {
-			XPropertyEvent pe;
+			XEvent e;
 
-			XNextEvent(display->dpy, (XEvent *)&pe);
-			DBG(("%s: reading event type %d\n", DisplayString(display->dpy), pe.type));
+			XNextEvent(display->dpy, &e);
+			DBG(("%s: reading event type %d\n", DisplayString(display->dpy), e.type));
 
-			if (pe.type == PropertyNotify &&
-			    pe.atom == ctx->singleton)
+			if (e.type == PropertyNotify &&
+			    ((XPropertyEvent *)&e)->atom == ctx->singleton)
 				return 0;
 		}
 	} while (1);
commit dd5f17ed3adf0c4e7c642f685f61766d12247c0e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Sep 2 15:13:44 2013 +0100

    intel-virtual-output: Decouple the fake mode before deleting
    
    When we install a fake mode on the output, we have to perform a
    round-trip for a reprobe. During that time, some other client (such as
    gnome-shell) will be notify of the change in output status and may
    attempt to configure it. This leaves us unable to delete the mode as it
    is currently active - so first disable the new head and then delete the
    mode.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/tools/virtual.c b/tools/virtual.c
index 5d2932a..ffac700 100644
--- a/tools/virtual.c
+++ b/tools/virtual.c
@@ -386,6 +386,7 @@ static RROutput claim_virtual(struct display *display, const char *name)
 	char buf[] = "ClaimVirtualHead";
 	Display *dpy = display->dpy;
 	XRRScreenResources *res;
+	XRROutputInfo *output;
 	XRRModeInfo mode;
 	RRMode id;
 	RROutput rr_output;
@@ -398,10 +399,14 @@ static RROutput claim_virtual(struct display *display, const char *name)
 		return 0;
 
 	for (i = rr_output = 0; rr_output == 0 && i < res->noutput; i++) {
-		XRROutputInfo *o = XRRGetOutputInfo(dpy, res, res->outputs[i]);
-		if (strcmp(o->name, name) == 0)
+		output = XRRGetOutputInfo(dpy, res, res->outputs[i]);
+		if (output == NULL)
+			continue;
+
+		if (strcmp(output->name, name) == 0)
 			rr_output = res->outputs[i];
-		XRRFreeOutputInfo(o);
+
+		XRRFreeOutputInfo(output);
 	}
 	for (i = id = 0; id == 0 && i < res->nmode; i++) {
 		if (strcmp(res->modes[i].name, buf) == 0)
@@ -428,6 +433,15 @@ static RROutput claim_virtual(struct display *display, const char *name)
 	res = XRRGetScreenResources(dpy, display->root);
 	if (res == NULL)
 		return 0;
+
+	/* Some else may have interrupted us and installed that new mode! */
+	output = XRRGetOutputInfo(dpy, res, rr_output);
+	if (output) {
+		if (output->crtc)
+			XRRSetCrtcConfig(dpy, res, output->crtc, CurrentTime,
+					 0, 0, None, RR_Rotate_0, NULL, 0);
+		XRRFreeOutputInfo(output);
+	}
 	XRRFreeScreenResources(res);
 
 	XRRDeleteOutputMode(dpy, rr_output, id);


More information about the xorg-commit mailing list