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 DF4D5A00E6 for ; Fri, 17 May 2019 10:15:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8F0AA2BA5; Fri, 17 May 2019 10:15:58 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id C8F082B9D for ; Fri, 17 May 2019 10:15:56 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B28F307E051; Fri, 17 May 2019 08:15:46 +0000 (UTC) Received: from dmarchan.remote.csb (ovpn-116-80.ams2.redhat.com [10.36.116.80]) by smtp.corp.redhat.com (Postfix) with ESMTP id EAD005D6A9; Fri, 17 May 2019 08:15:40 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: jfreimann@redhat.com, Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Date: Fri, 17 May 2019 10:15:08 +0200 Message-Id: <1558080908-25951-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 17 May 2019 08:15:54 +0000 (UTC) Subject: [dpdk-dev] [PATCH] ethdev: add a check on mempool during rxq setup 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" We currently have no check on the mempool pointer passed to rte_eth_rx_queue_setup. Let's avoid a plain crash when dereferencing it. Suggested-by: Jens Freimann Signed-off-by: David Marchand --- lib/librte_ethdev/rte_ethdev.c | 5 +++++ lib/librte_ethdev/rte_ethdev.h | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index d7cfa3d..76453fe 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1579,6 +1579,11 @@ struct rte_eth_dev * return -EINVAL; } + if (mp == NULL) { + RTE_ETHDEV_LOG(ERR, "Invalid null mempool pointer\n"); + return -EINVAL; + } + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP); RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_setup, -ENOTSUP); diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 80e371b..d7b2657 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1745,9 +1745,9 @@ int rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_queue, * @return * - 0: Success, receive queue correctly set up. * - -EIO: if device is removed. - * - -EINVAL: The size of network buffers which can be allocated from the - * memory pool does not fit the various buffer sizes allowed by the - * device controller. + * - -EINVAL: The memory pool pointer is null or the size of network buffers + * which can be allocated from this memory pool does not fit the various + * buffer sizes allowed by the device controller. * - -ENOMEM: Unable to allocate the receive ring descriptors or to * allocate network memory buffers from the memory pool when * initializing receive descriptors. -- 1.8.3.1