From nobody Sat Apr 27 22:32:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512989837036937.1746685668545; Mon, 11 Dec 2017 02:57:17 -0800 (PST) Received: from localhost ([::1]:52236 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOLlf-0005xd-CV for importer@patchew.org; Mon, 11 Dec 2017 05:57:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOLkk-0005bt-OU for qemu-devel@nongnu.org; Mon, 11 Dec 2017 05:56:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eOLkj-0001zW-Um for qemu-devel@nongnu.org; Mon, 11 Dec 2017 05:56:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58900) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eOLkf-0001uy-Iz; Mon, 11 Dec 2017 05:56:01 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 488AD6A7C1; Mon, 11 Dec 2017 10:55:59 +0000 (UTC) Received: from localhost.localdomain (vpn2-54-44.bne.redhat.com [10.64.54.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C1BA717515; Mon, 11 Dec 2017 10:55:54 +0000 (UTC) From: P J P To: Qemu Developers Date: Mon, 11 Dec 2017 16:25:46 +0530 Message-Id: <20171211105546.16466-1-ppandit@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 11 Dec 2017 10:55:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] display: check irq handler index before access X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org, Moguofang , Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Prasad J Pandit The ctz32() routine could return value greater than TC6393XB_GPIOS=3D16. This could lead to an OOB array access. Add check to avoid it. Reported-by: Moguofang Signed-off-by: Prasad J Pandit --- hw/display/tc6393xb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c index 74d10af3d4..78292cb847 100644 --- a/hw/display/tc6393xb.c +++ b/hw/display/tc6393xb.c @@ -175,6 +175,10 @@ static void tc6393xb_gpio_handler_update(TC6393xbState= *s) =20 for (diff =3D s->prev_level ^ level; diff; diff ^=3D 1 << bit) { bit =3D ctz32(diff); + if (bit >=3D TC6393XB_GPIOS) { + fprintf(stderr, "TC6393xb: no GPIO pin %d\n", bit); + return; + } qemu_set_irq(s->handler[bit], (level >> bit) & 1); } =20 --=20 2.13.6