ethdev: add size and align to compose dma zone name strings

Message ID 1556354324-28644-1-git-send-email-wangyunjian@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series ethdev: add size and align to compose dma zone name strings |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues
ci/Performance-Testing fail build patch failure

Commit Message

Yunjian Wang April 27, 2019, 8:38 a.m. UTC
  From: Yunjian Wang <wangyunjian@huawei.com>

The current dma zone name consists of the port_id, queue_id and
ring_name. If a port_id is reused, a new nic maybe use same dma
zone name. At this time, the zone size of the new driver is
differnt. When the zone is reused, it may cause illegal access
to memory.

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 lib/librte_ethdev/rte_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Patch

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index d7cfa3d..3242737 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -3630,9 +3630,9 @@  int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
 	const struct rte_memzone *mz;
 	int rc;
 
-	rc = snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s",
+	rc = snprintf(z_name, sizeof(z_name), "p%dq%d%s0x%zx_%d",
 		      dev->data->port_id, queue_id, ring_name);
-	if (rc >= RTE_MEMZONE_NAMESIZE) {
+	if (rc >= RTE_MEMZONE_NAMESIZE || rx < 0) {
 		RTE_ETHDEV_LOG(ERR, "ring name too long\n");
 		rte_errno = ENAMETOOLONG;
 		return NULL;