From patchwork Thu Oct 27 14:42:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 79683 Delivered-To: patch@linaro.org Received: by 10.80.142.83 with SMTP id 19csp683352edx; Thu, 27 Oct 2016 07:43:31 -0700 (PDT) X-Received: by 10.13.213.134 with SMTP id x128mr1939631ywd.187.1477579411473; Thu, 27 Oct 2016 07:43:31 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 140si2838602ywg.180.2016.10.27.07.43.30; Thu, 27 Oct 2016 07:43:31 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 64574608E5; Thu, 27 Oct 2016 14:43:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 0FFEA6083F; Thu, 27 Oct 2016 14:43:25 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 2794160844; Thu, 27 Oct 2016 14:43:21 +0000 (UTC) Received: from mail-lf0-f46.google.com (mail-lf0-f46.google.com [209.85.215.46]) by lists.linaro.org (Postfix) with ESMTPS id 31505607F8 for ; Thu, 27 Oct 2016 14:43:17 +0000 (UTC) Received: by mail-lf0-f46.google.com with SMTP id b75so33467455lfg.3 for ; Thu, 27 Oct 2016 07:43:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3TB3IjoFlUBEiEBJuzWs4KDEfZd4OPFDiUL4bCpiUKI=; b=VS80Hl6sv10ToT2HzDnmU6oCPSHr8WAts3URAlqQkCVDAoHReT/IRgUZgL4yvts6cX dIqa0vt3tq6FQFEwDfjIGq7RHMbN0a61qSSP2k2iprRw38x/uan3G5kwAVKWONumrEIR pg7UykISfVKzgX2CSrosKEy5GHFhxgcXSmXwFdeDPbdVbDAINi7MwlD4M33ZFUS5QuPz EpeeFTObQ/0lh/H8VdygG/B0GQiaNitWt1gVVVhJvJJpXRipzCw3FeUEAt2grELk1GfA wpGLyVdRKF+A77UHE3aLOtwyWClppQMPDJDu2ItFYX8yCKsnzu6qwTPUjMtg+RgfnGPP EtBg== X-Gm-Message-State: ABUngveFJm6E3ix1p9RPK8lCJoa0tW+a9fCI5Ns4V488FlwW+YD/zC/ts5G8Q2m/8UfDsu5x+gA= X-Received: by 10.25.23.228 with SMTP id 97mr205044lfx.167.1477579395959; Thu, 27 Oct 2016 07:43:15 -0700 (PDT) Received: from localhost.localdomain (ppp46-138-205-38.pppoe.spdop.ru. [46.138.205.38]) by smtp.gmail.com with ESMTPSA id h68sm1329651lji.20.2016.10.27.07.43.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Oct 2016 07:43:14 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 27 Oct 2016 17:42:48 +0300 Message-Id: <1477579368-7294-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 X-Topics: patch Subject: [lng-odp] [PATCH] linux-gen: sysinfo: check for overflow X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" In near future cpu mhz more likely will not overflow 64 bit value, but it makes sense to add assert for overflow check. https://bugs.linaro.org/show_bug.cgi?id=2425 Signed-off-by: Maxim Uvarov --- platform/linux-generic/arch/x86/odp_sysinfo_parse.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.7.1.250.gff4ea60 diff --git a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c index 96127ec..5aefd81 100644 --- a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c +++ b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c @@ -5,7 +5,9 @@ */ #include +#include #include +#include int cpuinfo_parser(FILE *file, system_info_t *sysinfo) { @@ -68,8 +70,11 @@ uint64_t odp_cpu_hz_current(int id) } fclose(file); - if (mhz) + if (mhz) { + /* check for overflow */ + ODP_ASSERT((ULLONG_MAX / 1000000) > mhz); return (uint64_t)(mhz * 1000000.0); + } return 0; }