video: dcu: fixup memory correct even without framebuffer
authorStefan Agner <stefan.agner@toradex.com>
Mon, 11 May 2015 06:28:52 +0000 (08:28 +0200)
committerStefan Agner <stefan.agner@toradex.com>
Mon, 11 May 2015 06:28:52 +0000 (08:28 +0200)
When there is no framebuffer allocated, e.g. no video environment
variable or an error during initialization, the framebuffer location
ends up to be NULL, in which case the fixup function calculates a
bogus memory size. Use the framebuffer size to make sure that memory
size is calculated right in any case.

drivers/video/fsl_dcu_fb.c

index 4ee823e1d32dbae840f6b26a87313bf4d33e5124..e7e385a2ed8a624ac96c9e2b76878dc684fa3119 100644 (file)
@@ -307,8 +307,10 @@ int fsl_dcu_init(unsigned int xres, unsigned int yres,
        info.screen_size =
                info.var.xres * info.var.yres * (info.var.bits_per_pixel / 8);
 
-       if (info.screen_size > CONFIG_FSL_DCU_MAX_FB_SIZE)
+       if (info.screen_size > CONFIG_FSL_DCU_MAX_FB_SIZE) {
+               info.screen_size = 0;
                return -ENOMEM;
+       }
 
        /* Reserve framebuffer at the end of memory */
        gd->fb_base = gd->bd->bi_dram[0].start +
@@ -444,7 +446,7 @@ int fsl_dcu_fixedfb_setup(void *blob)
        int ret;
 
        start = gd->bd->bi_dram[0].start;
-       size = gd->fb_base - gd->bd->bi_dram[0].start;
+       size = gd->bd->bi_dram[0].size - info.screen_size;
 
        /*
         * Align size on section size (1 MiB). The Linux kernel would crash