DPDK patches and discussions
 help / color / mirror / Atom feed
From: Haiyang Tan <haiyangtan@tencent.com>
To: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Cc: dev@dpdk.org, Haiyang Tan <haiyangtan@tencent.com>
Subject: [dpdk-dev] [PATCH] hash: fix possible uninitialized variable
Date: Sat, 22 Dec 2018 04:10:59 -0800	[thread overview]
Message-ID: <20181222121100.52827-1-haiyangtan@tencent.com> (raw)

The uninitialized field 'extra_flag' of hash_cuckoo_params may enable
certain feature silently. Typically, if bit0 of 'extra_flag' set, the
hardware transactional memory support will be enabled unexpectedly.

Signed-off-by: Haiyang Tan <haiyangtan@tencent.com>
---
 lib/librte_table/rte_table_hash_cuckoo.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/lib/librte_table/rte_table_hash_cuckoo.c b/lib/librte_table/rte_table_hash_cuckoo.c
index f02430333..25fc3a10b 100644
--- a/lib/librte_table/rte_table_hash_cuckoo.c
+++ b/lib/librte_table/rte_table_hash_cuckoo.c
@@ -82,6 +82,7 @@ rte_table_hash_cuckoo_create(void *params,
 			uint32_t entry_size)
 {
 	struct rte_table_hash_cuckoo_params *p = params;
+	struct rte_hash_parameters hash_cuckoo_params = { 0 };
 	struct rte_hash *h_table;
 	struct rte_table_hash *t;
 	uint32_t total_size;
@@ -103,14 +104,12 @@ rte_table_hash_cuckoo_create(void *params,
 	}
 
 	/* Create cuckoo hash table */
-	struct rte_hash_parameters hash_cuckoo_params = {
-		.entries = p->n_keys,
-		.key_len = p->key_size,
-		.hash_func = p->f_hash,
-		.hash_func_init_val = p->seed,
-		.socket_id = socket_id,
-		.name = p->name
-	};
+	hash_cuckoo_params.entries = p->n_keys;
+	hash_cuckoo_params.key_len = p->key_size;
+	hash_cuckoo_params.hash_func = p->f_hash;
+	hash_cuckoo_params.hash_func_init_val = p->seed;
+	hash_cuckoo_params.socket_id = socket_id;
+	hash_cuckoo_params.name = p->name;
 
 	h_table = rte_hash_find_existing(p->name);
 	if (h_table == NULL) {
-- 
2.14.1

             reply	other threads:[~2018-12-22 12:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-22 12:10 Haiyang Tan [this message]
2018-12-23  7:43 ` Stephen Hemminger
2018-12-24 10:30   ` Dumitrescu, Cristian

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=20181222121100.52827-1-haiyangtan@tencent.com \
    --to=haiyangtan@tencent.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    /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).