From patchwork Mon Jan 2 22:24:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 9494179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B82A2606A6 for ; Mon, 2 Jan 2017 22:26:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB9911FF27 for ; Mon, 2 Jan 2017 22:26:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A05A72679B; Mon, 2 Jan 2017 22:26:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4802024560 for ; Mon, 2 Jan 2017 22:26:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756353AbdABWZi (ORCPT ); Mon, 2 Jan 2017 17:25:38 -0500 Received: from botnar.kaiser.cx ([176.28.20.183]:41966 "EHLO botnar.kaiser.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933722AbdABWYi (ORCPT ); Mon, 2 Jan 2017 17:24:38 -0500 Received: from p4fd78b12.dip0.t-ipconnect.de ([79.215.139.18] helo=reykholt.kaiser.cx) by botnar.kaiser.cx with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1cOB1v-00070h-1f; Mon, 02 Jan 2017 23:24:35 +0100 From: Martin Kaiser To: b.zolnierkie@samsung.com, kernel@pengutronix.de Cc: linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH] video: imxfb: always allocate 256 entries for the color map Date: Mon, 2 Jan 2017 23:24:02 +0100 Message-Id: <1483395842-9675-1-git-send-email-martin@kaiser.cx> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1483395604-6931-1-git-send-email-martin@kaiser.cx> References: <1483395604-6931-1-git-send-email-martin@kaiser.cx> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Sascha Hauer --- Re-sending: corrected a typo in the LKML address, sorry for that. drivers/video/fbdev/imxfb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/imxfb.c b/drivers/video/fbdev/imxfb.c index fe0c4ee..1b0faad 100644 --- a/drivers/video/fbdev/imxfb.c +++ b/drivers/video/fbdev/imxfb.c @@ -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;