ethdev: add a check on mempool during rxq setup
PATCH 1/1 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 <[email protected]>
Signed-off-by David Marchand <[email protected]>
--- lib/librte_ethdev/rte_ethdev.c | 5 +++++ lib/librte_ethdev/rte_ethdev.h | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-)
lib/librte_ethdev/rte_ethdev.c +5 -0
@@ -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 );
lib/librte_ethdev/rte_ethdev.h +3 -3
@@ -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.
Signature · 1 line
1.8.3.1
Quoted 11 lines · David Marchand
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 <[email protected]>Signed-off-by David Marchand <[email protected]>---
lib/librte_ethdev/rte_ethdev.c| 5 +++++lib/librte_ethdev/rte_ethdev.h| 6 +++---2 files changed, 8 insertions(+), 3 deletions(-)
Thanks David!
Reviewed-by Jens Freimann <[email protected]>
Quoted 6 lines · David Marchand
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 <[email protected]>Signed-off-by David Marchand <[email protected]>
Acked-by Andrew Rybchenko <[email protected]>
Ferruh Yigit
AppliedQuoted 10 lines · Andrew Rybchenko
Quoted 6 lines · David Marchand
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 <[email protected]>Signed-off-by David Marchand <[email protected]>Acked-by Andrew Rybchenko <[email protected]>
Applied to dpdk-next-net/master, thanks.