From 26b23beb106fb3219d2ab85548445cede698918b Mon Sep 17 00:00:00 2001 From: Michal Srb Date: Thu, 15 Nov 2018 15:09:47 +0100 Subject: [PATCH] dix: Ignore initialized flag for screen-specific privates The dixRegisterScreenSpecificPrivateKey function ignores attempts to register the same key twice. Unlike dixRegisterPrivateKey, it can not use the "initialized" flag because there is no good place where to set it to FALSE during reset. Setting it before CloseScreen makes the keys unuseable in CloseScreen. Setting it after CloseScreen is not possible because some keys may have been deallocated by CloseScreen. Instead just search the list and ignore keys that are already there. The dixFreeScreenSpecificPrivates is left empty as it was before 82eb490. Signed-off-by: Michal Srb Fixes: 82eb490 (privates: Clear screen-specific keys during CloseScreen) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108762 --- dix/privates.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/dix/privates.c b/dix/privates.c index 9ca80f0b6..6c31500e4 100644 --- a/dix/privates.c +++ b/dix/privates.c @@ -600,14 +600,22 @@ dixRegisterScreenSpecificPrivateKey(ScreenPtr pScreen, DevPrivateKey key, { int offset; unsigned bytes; + DevPrivateKey iter; if (!screen_specific_private[type]) FatalError("Attempt to allocate screen-specific private storage for type %s\n", key_names[type]); - if (key->initialized) { - assert(size == key->size); - return TRUE; + /* + * We can not simply check key->initialized, because there is no + * reasonable place where it could be set to FALSE during internal reset. + */ + for (iter = pScreen->screenSpecificPrivates[type].key; iter; + iter = iter->next) { + if (iter == key) { + assert(size == key->size); + return TRUE; + } } /* Compute required space */ @@ -639,15 +647,6 @@ dixRegisterScreenSpecificPrivateKey(ScreenPtr pScreen, DevPrivateKey key, void dixFreeScreenSpecificPrivates(ScreenPtr pScreen) { - DevPrivateType t; - - for (t = PRIVATE_XSELINUX; t < PRIVATE_LAST; t++) { - DevPrivateKey key; - - for (key = pScreen->screenSpecificPrivates[t].key; key; key = key->next) { - key->initialized = FALSE; - } - } } /* Initialize screen-specific privates in AddScreen */ -- 2.16.4