DPDK patches and discussions
 help / color / mirror / Atom feed
From: wangyunjian <wangyunjian@huawei.com>
To: <dev@dpdk.org>
Cc: <xudingke@huawei.com>, Yunjian Wang <wangyunjian@huawei.com>
Subject: [dpdk-dev] [PATCH] ethdev: add size and align to compose dma zone name strings
Date: Sat, 27 Apr 2019 16:38:44 +0800	[thread overview]
Message-ID: <1556354324-28644-1-git-send-email-wangyunjian@huawei.com> (raw)

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(-)

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;
-- 
1.8.3.1

             reply	other threads:[~2019-04-27  8:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-27  8:38 wangyunjian [this message]
2019-04-27  8:38 ` wangyunjian
2019-04-27  9:47 wangyunjian
2019-04-27  9:47 ` wangyunjian
2019-04-29  8:03 ` David Marchand
2019-04-29  8:03   ` David Marchand
2019-05-08 13:52   ` Andrew Rybchenko
2019-05-08 13:52     ` Andrew Rybchenko

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=1556354324-28644-1-git-send-email-wangyunjian@huawei.com \
    --to=wangyunjian@huawei.com \
    --cc=dev@dpdk.org \
    --cc=xudingke@huawei.com \
    /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).