From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nithin Kumar Dabilpuram Subject: [PATCH] ethdev: report error on name truncation Date: Mon, 7 Jan 2019 14:40:05 +0000 Message-ID: <20190107143951.30076-1-ndabilpuram@marvell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" , Jerin Jacob Kollanukkaran , Nithin Kumar Dabilpuram To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Return-path: Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id EE4061B3FB for ; Mon, 7 Jan 2019 15:40:09 +0100 (CET) Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Nithin Dabilpuram --- lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.= c index 9d5107d..bd45445 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -3588,9 +3588,17 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *d= ev, const char *ring_name, { char z_name[RTE_MEMZONE_NAMESIZE]; const struct rte_memzone *mz; + int rc; =20 - snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s", - dev->data->port_id, queue_id, ring_name); + rc =3D snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d", + dev->device->driver->name, ring_name, + dev->data->port_id, queue_id); + + if (rc >=3D RTE_MEMZONE_NAMESIZE) { + RTE_LOG(ERR, EAL, "%s(): truncated name\n", __func__); + rte_errno =3D ENAMETOOLONG; + return NULL; + } =20 mz =3D rte_memzone_lookup(z_name); if (mz) --=20 2.8.4