From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id EF74899A4 for ; Mon, 31 Jul 2017 03:41:39 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jul 2017 18:41:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,439,1496127600"; d="scan'208";a="117494536" Received: from dpdk15.sh.intel.com ([10.67.111.77]) by orsmga002.jf.intel.com with ESMTP; 30 Jul 2017 18:41:37 -0700 From: Jiayu Hu To: dev@dpdk.org Cc: thomas@monjalon.net, jianfeng.tan@intel.com, Jiayu Hu Date: Mon, 31 Jul 2017 09:43:24 +0800 Message-Id: <1501465404-111602-1-git-send-email-jiayu.hu@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] lib/gro: fix bitwise overflow issue 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: , X-List-Received-Date: Mon, 31 Jul 2017 01:41:41 -0000 When try to get GRO types, expression "1 << i" with type "int" may overflow. This patch is to fix this issue. Fixes: e996506a1c07 ("lib/gro: add Generic Receive Offload API framework") Coverity issue: 158664 Signed-off-by: Jiayu Hu --- lib/librte_gro/rte_gro.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/librte_gro/rte_gro.c b/lib/librte_gro/rte_gro.c index 4998b90..7853246 100644 --- a/lib/librte_gro/rte_gro.c +++ b/lib/librte_gro/rte_gro.c @@ -81,7 +81,7 @@ rte_gro_ctx_create(const struct rte_gro_param *param) return NULL; for (i = 0; i < RTE_GRO_TYPE_MAX_NUM; i++) { - gro_type_flag = 1 << i; + gro_type_flag = 1ULL << i; if ((param->gro_types & gro_type_flag) == 0) continue; @@ -116,7 +116,7 @@ rte_gro_ctx_destroy(void *ctx) if (gro_ctx == NULL) return; for (i = 0; i < RTE_GRO_TYPE_MAX_NUM; i++) { - gro_type_flag = 1 << i; + gro_type_flag = 1ULL << i; if ((gro_ctx->gro_types & gro_type_flag) == 0) continue; destroy_tbl_fn = tbl_destroy_fn[i]; @@ -265,7 +265,7 @@ rte_gro_get_pkt_count(void *ctx) uint8_t i; for (i = 0; i < RTE_GRO_TYPE_MAX_NUM; i++) { - gro_type_flag = 1 << i; + gro_type_flag = 1ULL << i; if ((gro_ctx->gro_types & gro_type_flag) == 0) continue; -- 2.7.4