From 7d49e0f4a979206ec8faa2f64c69a771b8c27d14 Mon Sep 17 00:00:00 2001 From: Pablo de Lara Date: Mon, 31 Aug 2015 14:30:03 +0100 Subject: [PATCH] hash: fix memory allocation of cuckoo key table When calculating the size for the table which allocates the keys, size was calculated wrongly from multiplying two 32-bit variables, resulting on a 32-bit number, before casting to 64-bit, so maximum size was 4G. Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation") Signed-off-by: Pablo de Lara --- lib/librte_hash/rte_cuckoo_hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c index 4da859a6b7..70197638b9 100644 --- a/lib/librte_hash/rte_cuckoo_hash.c +++ b/lib/librte_hash/rte_cuckoo_hash.c @@ -238,7 +238,7 @@ rte_hash_create(const struct rte_hash_parameters *params) const uint32_t key_entry_size = sizeof(struct rte_hash_key) + params->key_len; /* Store all keys and leave the first entry as a dummy entry for lookup_bulk */ - const uint64_t key_tbl_size = key_entry_size * (params->entries + 1); + const uint64_t key_tbl_size = (uint64_t) key_entry_size * (params->entries + 1); k = rte_zmalloc_socket(NULL, key_tbl_size, RTE_CACHE_LINE_SIZE, params->socket_id); -- 2.20.1