From patchwork Mon Dec 11 10:55:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prasad Pandit X-Patchwork-Id: 10104765 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 AED19602A7 for ; Mon, 11 Dec 2017 10:56:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC13F2953D for ; Mon, 11 Dec 2017 10:56:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0CC529542; Mon, 11 Dec 2017 10:56:50 +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 lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2CEFB2953D for ; Mon, 11 Dec 2017 10:56:49 +0000 (UTC) Received: from localhost ([::1]:52236 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOLlQ-0005xd-Ie for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Dec 2017 05:56:48 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Prasad J Pandit The ctz32() routine could return value greater than TC6393XB_GPIOS=16. 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) for (diff = s->prev_level ^ level; diff; diff ^= 1 << bit) { bit = ctz32(diff); + if (bit >= TC6393XB_GPIOS) { + fprintf(stderr, "TC6393xb: no GPIO pin %d\n", bit); + return; + } qemu_set_irq(s->handler[bit], (level >> bit) & 1); }