Skip to content

Commit

Permalink
video: fbdev: imxfb: always allocate 256 entries for the color map
Browse files Browse the repository at this point in the history
The current code calculates the number of color map entries as
1 << info->var.bits_per_pixel. For 32bpp modes, 1 << 32 is 0 when
written to an int variable. As a consequence, the subsequent copying
of the default (non-empty) color map into our newly allocated color map
fails and imxfb's probe function returns an error.

On both imx1 and imx21 platforms, the color map is used only for modes
with <= 8bpp. By allocating 256 entries for the color map, we're on the
safe side.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
  • Loading branch information
Martin Kaiser authored and Bartlomiej Zolnierkiewicz committed Jan 11, 2017
1 parent d67fa87 commit dc31212
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/video/fbdev/imxfb.c
Original file line number Diff line number Diff line change
@@ -985,7 +985,11 @@ static int imxfb_probe(struct platform_device *pdev)
*/
imxfb_check_var(&info->var, info);

ret = fb_alloc_cmap(&info->cmap, 1 << info->var.bits_per_pixel, 0);
/*
* For modes > 8bpp, the color map is bypassed.
* Therefore, 256 entries are enough.
*/
ret = fb_alloc_cmap(&info->cmap, 256, 0);
if (ret < 0)
goto failed_cmap;

0 comments on commit dc31212

Please sign in to comment.