From a800d84c63fce033e3c1ca02e11f60c63850641e Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 11 May 2015 08:28:52 +0200 Subject: video: dcu: fixup memory correct even without framebuffer 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/video/fsl_dcu_fb.c b/drivers/video/fsl_dcu_fb.c index 4ee823e1d3..e7e385a2ed 100644 --- a/drivers/video/fsl_dcu_fb.c +++ b/drivers/video/fsl_dcu_fb.c @@ -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 -- cgit v1.2.3