From patchwork Thu May 8 18:46:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 29855 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D663820A67 for ; Thu, 8 May 2014 18:47:07 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id hr9sf2211225vcb.10 for ; Thu, 08 May 2014 11:47:07 -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:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=d4ghqffVdi2EM97Dctjk3ivz3magEDu8d5OB1n7OfYs=; b=Pa3gA0zFn8FJcbn4j3jlem9Bsyp4CV6fy6tm667Eing/O7qNvcxe5H+FZvP3q7QGxt 1MltvjlUw0ds93wc/btZiKqv0wneXXIDWHzuWk28kSxeCNZ01UWYTlncQjmUmPgWN1bL xd/++3Jfn1sNDoTk0Svf1t0j0uyFYdhJuGjRnEkvv5BmjPF4UDue3R79c8JxCqFzNP0E eeJiGchHOTq8ksKV1Mfxg+BY5BZWtZ61m8a4RhC/j/cugD4g8Zs3AQCDpMHPZm4L36H6 X+9BZtxTpwubl7MgYvn4NGD4gJSzZKHBVXel4c5QLMHMZvhtTw0tdb0eCcfruoSxtWGL NsTQ== X-Gm-Message-State: ALoCoQkJoO/sy8JznaIMa/F56kr/vYBFtx731sSiCt8nWjwBSYqHgZ+qL9e30j50S/qypdbhp3X8 X-Received: by 10.58.22.70 with SMTP id b6mr2538545vef.13.1399574827293; Thu, 08 May 2014 11:47:07 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.39.37 with SMTP id u34ls2620940qgu.4.gmail; Thu, 08 May 2014 11:47:07 -0700 (PDT) X-Received: by 10.52.139.6 with SMTP id qu6mr2006023vdb.67.1399574827176; Thu, 08 May 2014 11:47:07 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id mp4si318035vcb.112.2014.05.08.11.47.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 May 2014 11:47:07 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id jw12so3818737veb.34 for ; Thu, 08 May 2014 11:47:07 -0700 (PDT) X-Received: by 10.58.24.231 with SMTP id x7mr2058492vef.71.1399574827087; Thu, 08 May 2014 11:47:07 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp17023vcb; Thu, 8 May 2014 11:47:06 -0700 (PDT) X-Received: by 10.182.230.135 with SMTP id sy7mr7545768obc.24.1399574826255; Thu, 08 May 2014 11:47:06 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id yi3si944453pbb.11.2014.05.08.11.47.05 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 08 May 2014 11:47:06 -0700 (PDT) Received-SPF: none (google.com: pm215@archaic.org.uk does not designate permitted sender hosts) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WiTLO-00052v-S5; Thu, 08 May 2014 19:46:58 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Peter Crosthwaite Subject: [PATCH 6/8] hw/timer/exynos4210_mct: Avoid overflow in exynos4210_ltick_recalc_count Date: Thu, 8 May 2014 19:46:56 +0100 Message-Id: <1399574818-19349-7-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1399574818-19349-1-git-send-email-peter.maydell@linaro.org> References: <1399574818-19349-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 86f4fcd..69dbecd 100644 --- a/hw/timer/exynos4210_mct.c +++ b/hw/timer/exynos4210_mct.c @@ -824,14 +824,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; }