From patchwork Sun Jul 30 19:59:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 795425 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xLD266fdjz9s83 for ; Mon, 31 Jul 2017 05:59:42 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id B09ABC21E5A; Sun, 30 Jul 2017 19:59:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2A6CAC21D8D; Sun, 30 Jul 2017 19:59:36 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3639FC21D8D; Sun, 30 Jul 2017 19:59:34 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lists.denx.de (Postfix) with ESMTPS id DC205C21C58 for ; Sun, 30 Jul 2017 19:59:33 +0000 (UTC) Received: from LT002.fritz.box ([84.118.154.110]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0M8NBi-1dokCJ2U5q-00vy56; Sun, 30 Jul 2017 21:59:29 +0200 From: Heinrich Schuchardt To: Simon Glass Date: Sun, 30 Jul 2017 21:59:23 +0200 Message-Id: <20170730195923.22264-1-xypron.gl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V128wLfl25nnj7hxFMcKacEBC7AeYC4z97FqcEqnsKjH0NI/V kgmpbg6mQkdF8iDPXh8FH2xAel0dA== Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH 1/1] lcd: avoid possible NULL dereference X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Do not dereference bmp before the check if it is NULL. The problem was indicated by cppcheck. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Reviewed-by: Philipp Tomsich --- common/lcd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/lcd.c b/common/lcd.c index 7e399cee2d..35914960a5 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -578,7 +578,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y) unsigned long pwidth = panel_info.vl_col; unsigned colors, bpix, bmp_bpix; int hdr_size; - struct bmp_color_table_entry *palette = bmp->color_table; + struct bmp_color_table_entry *palette; if (!bmp || !(bmp->header.signature[0] == 'B' && bmp->header.signature[1] == 'M')) { @@ -587,6 +587,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y) return 1; } + palette = bmp->color_table; width = get_unaligned_le32(&bmp->header.width); height = get_unaligned_le32(&bmp->header.height); bmp_bpix = get_unaligned_le16(&bmp->header.bit_count);