s5pc110: fb: possible memory leak (un-free'd malloc)
[kernel/u-boot.git] / drivers / video / s5p-fb.c
index 73b910d..3e90e21 100644 (file)
@@ -27,6 +27,7 @@
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
 #include <lcd.h>
+#include <malloc.h>
 
 #include "s5p-fb.h"
 #include "logo.h"
@@ -51,6 +52,7 @@ short console_row;
 
 static unsigned int panel_width, panel_height;
 
+#ifdef USE_LCD_TEST
 static unsigned short makepixel565(char r, char g, char b)
 {
     return (unsigned short)(((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3));
@@ -90,6 +92,7 @@ static void read_image32(char* pImg, int x1pos, int y1pos, int x2pos,
                }
        }
 }
+#endif
 
 /* LCD Panel data */
 vidinfo_t panel_info;
@@ -117,6 +120,7 @@ static void s5pc_lcd_init(vidinfo_t *vid)
        s5pc_fimd_lcd_init(vid);
 }
 
+#ifdef USE_LCD_TEST
 static void lcd_test(unsigned int width, unsigned int height)
 {
        unsigned int height_level = height / 3;
@@ -131,6 +135,7 @@ static void lcd_test(unsigned int width, unsigned int height)
        read_image32((char *)lcd_base, 0, height_level * 2, width, height,
                        makepixel8888(0, 0, 0, 255));
 }
+#endif
 
 int conv_rgb565_to_rgb888(unsigned short rgb565, unsigned int sw)
 {
@@ -195,9 +200,9 @@ void _draw_samsung_logo(void *lcdbase, int x, int y, int w, int h, unsigned shor
 static void draw_samsung_logo(void* lcdbase)
 {
        int x, y;
-       unsigned int in_len,out_len, width, height;
+       unsigned int in_len, width, height;
+       unsigned long out_len;
        void *dst = NULL;
-
        width = 298;
        height = 78;
        x = ((panel_width - width) >> 1);
@@ -207,16 +212,17 @@ static void draw_samsung_logo(void* lcdbase)
        dst = malloc(in_len);
        if (dst == NULL) {
                printf("Error: malloc in gunzip failed!\n");
-               return NULL;
+               return;
        }
        if (gunzip(dst, in_len, (uchar *)logo, &out_len) != 0) {
                free(dst);
-               return NULL;
+               return;
        }
        if (out_len == CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)
                printf("Image could be truncated"
                                " (increase CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)!\n");
        _draw_samsung_logo(lcdbase, x, y, width, height, (unsigned short *) dst);
+       free(dst);
 }
 
 static void lcd_panel_on(vidinfo_t *vid)
@@ -226,38 +232,40 @@ static void lcd_panel_on(vidinfo_t *vid)
        if (vid->cfg_gpio)
                vid->cfg_gpio();
 
-       if (vid->lcd_power_on) {
+       if (vid->lcd_power_on)
                vid->lcd_power_on(1);
-       }
 
        udelay(vid->power_on_delay);
 
-       if (vid->reset_lcd) {
+       if (vid->reset_lcd)
                vid->reset_lcd();
-       }
 
        udelay(vid->reset_delay);
 
-       if (vid->backlight_on) {
+       if (vid->backlight_on)
                vid->backlight_on(1);
-       }
 
-       if (vid->cfg_ldo) {
+
+       if (vid->cfg_ldo)
                vid->cfg_ldo();
-       }
 
-       if (vid->enable_ldo) {
+
+       if (vid->enable_ldo)
                vid->enable_ldo(1);
-       }
+
 }
 
 /* extern void init_onenand_ext2(void); */
 extern void init_panel_info(vidinfo_t *vid);
+extern int s5p_no_lcd_support(void);
 
 void lcd_ctrl_init(void *lcdbase)
 {
        char *option;
 
+       if (s5p_no_lcd_support())
+               return;
+
        s5pc_lcd_init_mem(lcdbase, &panel_info);
 
        /* initialize parameters which is specific to panel. */
@@ -271,7 +279,9 @@ void lcd_ctrl_init(void *lcdbase)
        /*
        if (strcmp(option, "test") == 0) {
                memset(lcdbase, 0, PANEL_WIDTH*PANEL_HEIGHT*S5P_LCD_BPP >> 3);
+#ifdef USE_LCD_TEST
                lcd_test(panel_width, panel_height);
+#endif
        } else if (strcmp(option, "image") == 0)
                memcpy(lcdbase, LOGO_RGB24, PANEL_WIDTH*PANEL_HEIGHT*S5P_LCD_BPP >> 3);
        else {