From: Jiayu Hu <jiayu.hu@intel.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, jianfeng.tan@intel.com,
Jiayu Hu <jiayu.hu@intel.com>
Subject: [dpdk-dev] [PATCH] lib/gro: fix bitwise overflow issue
Date: Mon, 31 Jul 2017 09:43:24 +0800 [thread overview]
Message-ID: <1501465404-111602-1-git-send-email-jiayu.hu@intel.com> (raw)
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 <jiayu.hu@intel.com>
---
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
next reply other threads:[~2017-07-31 1:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-31 1:43 Jiayu Hu [this message]
2017-07-31 7:01 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1501465404-111602-1-git-send-email-jiayu.hu@intel.com \
--to=jiayu.hu@intel.com \
--cc=dev@dpdk.org \
--cc=jianfeng.tan@intel.com \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).