From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id E38A8A05D3 for ; Wed, 22 May 2019 08:48:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DD03514EC; Wed, 22 May 2019 08:48:35 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 51EE310BD; Wed, 22 May 2019 08:48:34 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2019 23:48:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,498,1549958400"; d="scan'208";a="174288205" Received: from dipei-st-npg.sh.intel.com ([10.67.110.220]) by fmsmga002.fm.intel.com with ESMTP; 21 May 2019 23:48:32 -0700 From: Andy Pei To: dev@dpdk.org Cc: andy.pei@intel.com, rosen.xu@intel.com, stable@dpdk.org Date: Wed, 22 May 2019 14:42:49 +0800 Message-Id: <1558507369-350703-1-git-send-email-andy.pei@intel.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] raw/ifpga: fix unintentional integer overflow X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" cast unsigned int ports_per_retimer, unsigned int nums_retimer, unsigned int nums_fvl and unsigned int ports_per_fvl to uint64_t before multiply operation, to avoid Unintentional integer overflow. Coverity issue: 337924, 337926 Fixes: d1cd4eb2d48e ("raw/ifpga: support ipn3ke") Cc: rosen.xu@intel.com Cc: stable@dpdk.org Signed-off-by: Andy Pei --- drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c index 41be1a2..9c68666 100644 --- a/drivers/raw/ifpga_rawdev/ifpga_rawdev.c +++ b/drivers/raw/ifpga_rawdev/ifpga_rawdev.c @@ -494,8 +494,8 @@ if (!strcmp(attr_name, "LineSideLinkPortNum")) { if (opae_manager_get_retimer_info(mgr, &opae_rtm_info)) return -1; - uint64_t tmp = opae_rtm_info.ports_per_retimer * - opae_rtm_info.nums_retimer; + uint64_t tmp = (uint64_t)opae_rtm_info.ports_per_retimer * + (uint64_t)opae_rtm_info.nums_retimer; *attr_value = tmp; return 0; } @@ -547,8 +547,8 @@ if (!strcmp(attr_name, "NICSideLinkPortNum")) { if (opae_manager_get_retimer_info(mgr, &opae_rtm_info)) return -1; - uint64_t tmp = opae_rtm_info.nums_fvl * - opae_rtm_info.ports_per_fvl; + uint64_t tmp = (uint64_t)opae_rtm_info.nums_fvl * + (uint64_t)opae_rtm_info.ports_per_fvl; *attr_value = tmp; return 0; } -- 1.8.3.1