gma500: Fix backlight crash
authorAlan Cox <alan@linux.intel.com>
Tue, 5 Jul 2011 14:44:34 +0000 (15:44 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 5 Jul 2011 15:20:44 +0000 (08:20 -0700)
We need to check the NULL case earlier.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/gma500/backlight.c

index 4027e700561a3de4508711396838803f20917d99..d3e698b4de6144df8100e1dd7dd7575fcb7f2049 100644 (file)
@@ -38,9 +38,10 @@ void gma_backlight_exit(struct drm_device *dev)
 {
 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
        struct drm_psb_private *dev_priv = dev->dev_private;
-       dev_priv->backlight_device->props.brightness = 0;
-       backlight_update_status(dev_priv->backlight_device);
-       if (dev_priv->backlight_device)
+       if (dev_priv->backlight_device) {
+               dev_priv->backlight_device->props.brightness = 0;
+               backlight_update_status(dev_priv->backlight_device);
                backlight_device_unregister(dev_priv->backlight_device);
+       }
 #endif
 }