[Openchrome-devel] Fix XVMC crash on shutdown

Daniel Drake dsd
Wed Jun 24 03:22:31 PDT 2009


ViaCleanupXVMC() causes a segfault during X shutdown on hardware where Xv
is not supported.

ViaCleanupXVMC() is always called during shutdown and always expects the
pointer values in the viaAdaptPtr array to have some meaningful value.
However, in the non-Xv case, this array will not have been initialized.
Initialize it to NULL in this situation.

The other function that uses this array, viaExitVideo(), already does a NULL
check when working with this array. Add a similar check to ViaCleanupXVMC()
to avoid the segfault.

Index: xf86-video-openchrome-0.2.903/src/via_video.c
===================================================================
--- xf86-video-openchrome-0.2.903.orig/src/via_video.c
+++ xf86-video-openchrome-0.2.903/src/via_video.c
@@ -600,6 +600,7 @@ viaInitVideo(ScreenPtr pScreen)
         xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
                 "[Xv] Unsupported Chipset. X video functionality disabled.\n");
         num_adaptors = 0;
+        memset(viaAdaptPtr, 0, sizeof(viaAdaptPtr));
     }
 
     DBG_DD(ErrorF(" via_video.c : num_adaptors : %d\n", num_adaptors));
Index: xf86-video-openchrome-0.2.903/src/via_xvmc.c
===================================================================
--- xf86-video-openchrome-0.2.903.orig/src/via_xvmc.c
+++ xf86-video-openchrome-0.2.903/src/via_xvmc.c
@@ -412,6 +412,9 @@ ViaCleanupXVMC(ScrnInfoPtr pScrn, XF86Vi
         cleanupViaXvMC(vXvMC, XvAdaptors, XvAdaptorCount);
     }
     for (i = 0; i < XvAdaptorCount; ++i) {
+        if (!XvAdaptors[i])
+            continue;
+
         for (j = 0; j < XvAdaptors[i]->nPorts; ++j) {
             viaPortPrivPtr pPriv = XvAdaptors[i]->pPortPrivates[j].ptr;
 




More information about the Openchrome-devel mailing list