Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc312120 authored by Martin Kaiser's avatar Martin Kaiser Committed by Bartlomiej Zolnierkiewicz
Browse files

video: fbdev: imxfb: always allocate 256 entries for the color map



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: default avatarMartin Kaiser <martin@kaiser.cx>
Acked-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
parent d67fa87d
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -985,7 +985,11 @@ static int imxfb_probe(struct platform_device *pdev)
	 */
	 */
	imxfb_check_var(&info->var, info);
	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)
	if (ret < 0)
		goto failed_cmap;
		goto failed_cmap;