From: David Marchand Date: Fri, 17 May 2019 08:15:08 +0000 (+0200) Subject: ethdev: add a check on mempool during RxQ setup X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=cd7bb0d442590ece3c493a7df263f7455a79b098;p=dpdk.git ethdev: add a check on mempool during RxQ setup 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 Reviewed-by: Jens Freimann Acked-by: Andrew Rybchenko --- diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 47546136a8..e54239cb6b 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1579,6 +1579,11 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, 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 5dd11afffd..6ed560cda1 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1745,9 +1745,9 @@ rte_eth_dev_is_removed(uint16_t port_id); * @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.