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.
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 +
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