From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 9A636A05D3 for ; Sat, 27 Apr 2019 10:39:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3125C1B675; Sat, 27 Apr 2019 10:39:22 +0200 (CEST) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by dpdk.org (Postfix) with ESMTP id 31E551B659 for ; Sat, 27 Apr 2019 10:39:18 +0200 (CEST) Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id C50DB7DB1CB5A0FF15C8 for ; Sat, 27 Apr 2019 16:39:14 +0800 (CST) Received: from localhost (10.177.24.66) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Sat, 27 Apr 2019 16:39:04 +0800 From: wangyunjian To: CC: , Yunjian Wang Date: Sat, 27 Apr 2019 16:38:44 +0800 Message-ID: <1556354324-28644-1-git-send-email-wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Originating-IP: [10.177.24.66] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH] ethdev: add size and align to compose dma zone name strings X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190427083844.f42ildhe5z9JeFosJih0fA1QFi2HICnQ5G327p3BBQs@z> From: Yunjian Wang 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 --- 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