From: Thomas Hellstrom Date: Tue, 15 Aug 2006 23:21:56 +0000 (+1000) Subject: drm: avoid kernel oops in some error paths calling drm_lastclose X-Git-Tag: v2.6.19-rc1~641^2~14 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a0c721dc5d0de011e5d363cd454c60c66ca00ec;p=linux-2.6 drm: avoid kernel oops in some error paths calling drm_lastclose Signed-off-by: Dave Airlie --- diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c index f9ecc8414b..654b95cdd9 100644 --- a/drivers/char/drm/drm_drv.c +++ b/drivers/char/drm/drm_drv.c @@ -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 */