]> err.no Git - linux-2.6/commitdiff
drm: avoid kernel oops in some error paths calling drm_lastclose
authorThomas Hellstrom <thomas@tungstengraphics.com>
Tue, 15 Aug 2006 23:21:56 +0000 (09:21 +1000)
committerDave Airlie <airlied@linux.ie>
Thu, 21 Sep 2006 19:32:32 +0000 (05:32 +1000)
Signed-off-by: Dave Airlie <airlied@linux.ie>
drivers/char/drm/drm_drv.c

index f9ecc8414b8a962d7773276485b5367e9b99cbef..654b95cdd9a3ddf378d3054d8f8c312afb27ddf4 100644 (file)
@@ -155,10 +155,12 @@ int drm_lastclose(drm_device_t * dev)
        del_timer(&dev->timer);
 
        /* Clear pid list */
-       list_for_each_entry_safe(pt, next, &dev->magicfree, head) {
-               list_del(&pt->head);
-               drm_ht_remove_item(&dev->magiclist, &pt->hash_item);
-               drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
+       if (dev->magicfree.next) {
+               list_for_each_entry_safe(pt, next, &dev->magicfree, head) {
+                       list_del(&pt->head);
+                       drm_ht_remove_item(&dev->magiclist, &pt->hash_item);
+                       drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
+               }
        }
 
        /* Clear AGP information */