From db82617464e55432522e6199a88408ff0187f6ff Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 4 Mar 2015 17:12:30 +0000 Subject: [PATCH] sna: Decouple RandR pointers early in CloseScreen RR resources are freed before CloseScreen (as they are a ServerClient resource), but on entering our CloseScreen callbacks we are left with a set of stale pointers. Decouple those before proceeding so that we are not tempted to dereference them. Bugzilla: https://bugs.archlinux.org/task/43906 Signed-off-by: Chris Wilson --- src/sna/sna_display.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 88db5088..fd6c46c4 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -6292,9 +6292,26 @@ sna_mode_enable(struct sna *sna) sna->mode.dirty = false; } +static void sna_randr_close(struct sna *sna) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(sna->scrn); + int n; + + /* The RR structs are freed early during CloseScreen as they + * are tracked as Resources. However, we may be tempted to + * access them during shutdown so decouple them now. + */ + for (n = 0; n < config->num_output; n++) + config->output[n]->randr_output = NULL; + + for (n = 0; n < config->num_crtc; n++) + config->crtc[n]->randr_crtc = NULL; +} + void sna_mode_close(struct sna *sna) { + sna_randr_close(sna); sna_mode_wakeup(sna); if (sna->flags & SNA_IS_HOSTED)