From nobody Fri May 17 08:24:53 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1604312433; cv=none; d=zohomail.com; s=zohoarc; b=UAWwEIt68OuU4D4glaa6ogcGNT54vADmaCSRBDrWFFz3EEkajsnDtOJzvVKa4qPGYk+WVzWWm5hDb92+4VNi7AgANCxw0Nsrp7mxezpJu1FgRcJysiN3jwy4AwugZ3bWPeGMYwzqf334iRNe5GB/NpiS3asw70dRKg995qmkk5U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604312433; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=khdwCmGk1mnMdNyiYE4l4Iej34g3d35JDxN7nzx5gUk=; b=DVCVzcW+NAtDygWxDKR6baId/UjuDz5wyl0C4JG9jLRHf2EOM1TSVEAB5fJ5BivjJgnKKOqtMzojAwdo6TtcWwZDlo8MM829y/HQSYXYF+SCxhGqZHKgJlNYAmfu2V1g59+MvJydrS3EkwDFyUgP0Jde9VToSlgynSDb2Tib5vs= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604312433666584.5123010532628; Mon, 2 Nov 2020 02:20:33 -0800 (PST) Received: from localhost ([::1]:36226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZWwy-0006OP-Gw for importer@patchew.org; Mon, 02 Nov 2020 05:20:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55416) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZWqB-0007hB-0Z; Mon, 02 Nov 2020 05:13:31 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:2067) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZWq9-00077m-2i; Mon, 02 Nov 2020 05:13:30 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4CPpdy3gVHzhfYX; Mon, 2 Nov 2020 18:13:26 +0800 (CST) Received: from [10.174.187.138] (10.174.187.138) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Mon, 2 Nov 2020 18:13:17 +0800 Message-ID: <5F9FDBBD.4020607@huawei.com> Date: Mon, 2 Nov 2020 18:13:17 +0800 From: AlexChen User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Subject: [PATCH V3] hw/display/exynos4210_fimd: Fix potential NULL pointer dereference References: <5F9F8D88.9030102@huawei.com> In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.187.138] X-CFilter-Loop: Reflected Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.32; envelope-from=alex.chen@huawei.com; helo=szxga06-in.huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 05:10:42 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: QEMU Trivial , Peter Maydell , qemu-arm , QEMU , zhang.zhanghailiang@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" In exynos4210_fimd_update(), the pointer 's' is dereferenced before checking it is valid, which may lead to NULL pointer dereference. So move the assignment to global_width after checking 's' is valid. Reported-by: Euler Robot Signed-off-by: Alex Chen Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/display/exynos4210_fimd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c index 4c16e1f5a0..34a960a976 100644 --- a/hw/display/exynos4210_fimd.c +++ b/hw/display/exynos4210_fimd.c @@ -1275,12 +1275,14 @@ static void exynos4210_fimd_update(void *opaque) bool blend =3D false; uint8_t *host_fb_addr; bool is_dirty =3D false; - const int global_width =3D (s->vidtcon[2] & FIMD_VIDTCON2_SIZE_MASK) += 1; + int global_width; if (!s || !s->console || !s->enabled || surface_bits_per_pixel(qemu_console_surface(s->console)) =3D=3D 0)= { return; } + + global_width =3D (s->vidtcon[2] & FIMD_VIDTCON2_SIZE_MASK) + 1; exynos4210_update_resolution(s); surface =3D qemu_console_surface(s->console); --=20 2.19.1