sna: Handle char *backlight_iface
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 30 Jan 2014 12:17:02 +0000 (12:17 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 30 Jan 2014 12:24:47 +0000 (12:24 +0000)
The backlight_iface is a freeable string, in places we were assigning a
constant string and later freeing it.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
src/sna/sna_display.c

index 0e9a07f..22f1841 100644 (file)
@@ -352,7 +352,7 @@ sna_output_backlight_init(xf86OutputPtr output)
 
        DBG(("%s: found 'wscons'\n", __FUNCTION__));
 
-       sna_output->backlight_iface = "wscons";
+       sna_output->backlight_iface = strdup("wscons");
        sna_output->backlight_max = param.max;
        sna_output->backlight_active_level = param.curval;
 }
@@ -471,14 +471,14 @@ has_user_backlight_override(xf86OutputPtr output)
 {
        struct sna_output *sna_output = output->driver_private;
        struct sna *sna = to_sna(output->scrn);
-       char *str;
+       const char *str;
        int max;
 
        str = xf86GetOptValString(sna->Options, OPTION_BACKLIGHT);
        if (str == NULL)
                return NULL;
 
-       sna_output->backlight_iface = str;
+       sna_output->backlight_iface = (char *)str;
        max = sna_output_backlight_get_max(output);
        sna_output->backlight_iface = NULL;
        if (max <= 0) {
@@ -488,7 +488,7 @@ has_user_backlight_override(xf86OutputPtr output)
                return NULL;
        }
 
-       return str;
+       return strdup(str);
 }
 
 static char *