From: Jiayu Hu Date: Mon, 31 Jul 2017 01:43:24 +0000 (+0800) Subject: gro: fix bitwise overflow X-Git-Tag: spdx-start~2339 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=ee9c90cf2fb1029cfe814669dd02eaf5bebffa2a;p=dpdk.git gro: fix bitwise overflow When try to get GRO types, expression "1 << i" with type "int" may overflow. This patch is to fix this issue. Coverity issue: 158664 Fixes: e996506a1c07 ("lib/gro: add Generic Receive Offload API framework") Signed-off-by: Jiayu Hu --- diff --git a/lib/librte_gro/rte_gro.c b/lib/librte_gro/rte_gro.c index 4998b90283..7853246ad0 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;