The map removal code was blithely freeing the lock structure, even if it was 
part of a _DRM_DRIVER mapping.  This caused X to crash at startup if you used 
a DRI aware driver.

Look good?  There may be a nicer way to do it...

Jesse
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index 6a3e704..df40e6a 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -175,7 +175,7 @@ int drm_lastclose(struct drm_device * dev)
 	struct drm_magic_entry *pt, *next;
 	struct drm_map_list *r_list, *list_t;
 	struct drm_vma_entry *vma, *vma_temp;
-	int i;
+	int i, free_lock = 1;
 
 	DRM_DEBUG("\n");
 
@@ -250,6 +250,9 @@ int drm_lastclose(struct drm_device * dev)
 	}
 
 	list_for_each_entry_safe(r_list, list_t, &dev->maplist, head) {
+		/* Don't remove the lock if it's driver mapped */
+		if (r_list->map->flags & (_DRM_DRIVER | _DRM_CONTAINS_LOCK))
+			free_lock = 0;
 		if (!(r_list->map->flags & _DRM_DRIVER)) {
 			drm_rmmap_locked(dev, r_list->map);
 			r_list = NULL;
@@ -276,7 +279,7 @@ int drm_lastclose(struct drm_device * dev)
 	if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
 		drm_dma_takedown(dev);
 
-	if (dev->lock.hw_lock) {
+	if (dev->lock.hw_lock && free_lock) {
 		dev->sigdata.lock = dev->lock.hw_lock = NULL;	/* SHM removed */
 		dev->lock.file_priv = NULL;
 		wake_up_interruptible(&dev->lock.lock_queue);
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to