dix: Ignore initialized flag for screen-specific privates

Submitted by Michal Srb on Nov. 23, 2018, 8:38 a.m.

Details

Message ID 20181123083859.15709-2-msrb@suse.com
State New
Headers show

Not browsing as part of any series.

Patch hide | download patch | download mbox

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 */