From patchwork Tue May 13 15:31:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 30072 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f198.google.com (mail-ve0-f198.google.com [209.85.128.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0901520369 for ; Tue, 13 May 2014 15:36:36 +0000 (UTC) Received: by mail-ve0-f198.google.com with SMTP id sa20sf1535602veb.1 for ; Tue, 13 May 2014 08:36:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=5e+YHs5x8YbJJQL1o57nk5RLSiEjsreK1br4JrnjDQ4=; b=VKRiJ/oSldVis/Jk1zVrLT6BWYAB5ZhZ82dh03hjvSUD+AT/XQ1Z6Uz8gCbpQ2bsZk +zzadGI25B8wpR5fS6VCWAY3XNMR+9kEfXxRVh0Dpnt7n7r6nsacH2ilHfiiiXQ178bg 13qloebjT89X9OeXwP42B2aSouKx8UwAv7+9WUxZn2Jq5MvqfFJftL/YRdmMrxxi50E4 m1jVE+h4bF5EhPfyxAdbZ3cZcYscgmYFv7HUrhQcioIIAFUYn65qzqKU/Q84EdTnatiX KFBAfENhRw5LP20IRXZZ/oZCMINK04H8EEXhnRyOfzRxiA2jKWBg2jWUz+4Bi94dD4pq oIQw== X-Gm-Message-State: ALoCoQkZZN5jjGDXC2GdVx6JnOLgDTd7/OtcA+NlViBiFCp2/UkJjK1FO332fgy5TqGmhPF4ibbQ X-Received: by 10.236.140.42 with SMTP id d30mr16765089yhj.2.1399995395681; Tue, 13 May 2014 08:36:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.32.203 with SMTP id h69ls1963017qgh.56.gmail; Tue, 13 May 2014 08:36:35 -0700 (PDT) X-Received: by 10.220.116.136 with SMTP id m8mr427784vcq.77.1399995395371; Tue, 13 May 2014 08:36:35 -0700 (PDT) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id z4si2711081vcp.132.2014.05.13.08.36.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 May 2014 08:36:35 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.170 as permitted sender) client-ip=209.85.128.170; Received: by mail-ve0-f170.google.com with SMTP id db11so679033veb.1 for ; Tue, 13 May 2014 08:36:35 -0700 (PDT) X-Received: by 10.58.38.40 with SMTP id d8mr679815vek.61.1399995395300; Tue, 13 May 2014 08:36:35 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp160767vcb; Tue, 13 May 2014 08:36:34 -0700 (PDT) X-Received: by 10.140.104.195 with SMTP id a61mr45634952qgf.102.1399995394728; Tue, 13 May 2014 08:36:34 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [208.118.235.17]) by mx.google.com with ESMTPS id a67si8018708qgf.20.2014.05.13.08.36.34 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 13 May 2014 08:36:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Received: from localhost ([::1]:45898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkEks-0005iG-CI for patch@linaro.org; Tue, 13 May 2014 11:36:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkEgI-0007zG-7x for qemu-devel@nongnu.org; Tue, 13 May 2014 11:31:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkEgG-000698-Ry for qemu-devel@nongnu.org; Tue, 13 May 2014 11:31:50 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:48125) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkEgG-00066p-MJ for qemu-devel@nongnu.org; Tue, 13 May 2014 11:31:48 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WkEg7-0006xT-VT; Tue, 13 May 2014 16:31:39 +0100 From: Peter Maydell To: Anthony Liguori Date: Tue, 13 May 2014 16:31:37 +0100 Message-Id: <1399995099-26635-16-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1399995099-26635-1-git-send-email-peter.maydell@linaro.org> References: <1399995099-26635-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 15/17] hw/timer/exynos4210_mct: Avoid overflow in exynos4210_ltick_recalc_count X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Add casts to avoid potentially overflowing the multiplications of 32 bit quantities in exynos4210_ltick_recalc_count(). Signed-off-by: Peter Maydell Reviewed-by: Peter Crosthwaite --- hw/timer/exynos4210_mct.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c index 01e750e..015bbaf 100644 --- a/hw/timer/exynos4210_mct.c +++ b/hw/timer/exynos4210_mct.c @@ -818,14 +818,14 @@ static void exynos4210_ltick_recalc_count(struct tick_timer *s) */ if (s->last_tcnto) { - to_count = s->last_tcnto * s->last_icnto; + to_count = (uint64_t)s->last_tcnto * s->last_icnto; } else { to_count = s->last_icnto; } } else { /* distance is passed, recalculate with tcnto * icnto */ if (s->icntb) { - s->distance = s->tcntb * s->icntb; + s->distance = (uint64_t)s->tcntb * s->icntb; } else { s->distance = s->tcntb; }