nouveau: Fix dereferencing a NULL pointer when erroring out during initialization.
authorMaarten Maathuis <madman2003@gmail.com>
Mon, 1 Oct 2007 20:21:23 +0000 (22:21 +0200)
committerMaarten Maathuis <madman2003@gmail.com>
Mon, 1 Oct 2007 20:21:23 +0000 (22:21 +0200)
shared-core/nouveau_state.c

index cba12b5..cb19c88 100644 (file)
@@ -423,12 +423,15 @@ void nouveau_lastclose(struct drm_device *dev)
 {
        struct drm_nouveau_private *dev_priv = dev->dev_private;
 
-       nouveau_card_takedown(dev);
-
-       if(dev_priv->fb_mtrr>0)
-       {
-               drm_mtrr_del(dev_priv->fb_mtrr, drm_get_resource_start(dev, 1),nouveau_mem_fb_amount(dev), DRM_MTRR_WC);
-               dev_priv->fb_mtrr=0;
+       /* In the case of an error dev_priv may not be be allocated yet */
+       if (dev_priv && dev_priv->card_type) {
+               nouveau_card_takedown(dev);
+
+               if(dev_priv->fb_mtrr>0)
+               {
+                       drm_mtrr_del(dev_priv->fb_mtrr, drm_get_resource_start(dev, 1),nouveau_mem_fb_amount(dev), DRM_MTRR_WC);
+                       dev_priv->fb_mtrr=0;
+               }
        }
 }