fs_rx_queue_release() and fs_tx_queue_release() iterate over the active
sub-devices and call the sub-device Rx/Tx queue release op directly.
Some PMDs do not implement that op, so the function pointer is NULL.
Calling it unconditionally could dereference a NULL pointer and crash
when releasing fail-safe queues.
Check that the sub-device provides the release op before calling it.
Fixes: a46f8d584eb8 ("net/failsafe: add fail-safe PMD")
Cc: [email protected]
Signed-off-by: Sandeep Penigalapati <[email protected]>
---
v2:
- Added an ETH(sdev) != NULL check.
v3:
- Removed the ETH(sdev) != NULL check (ETH(sdev) is never NULL for an
active sub-device) and corrected the Fixes tag.
drivers/net/failsafe/failsafe_ops.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/failsafe/failsafe_ops.c
b/drivers/net/failsafe/failsafe_ops.c
index 8761cb07c3..79aa57cb35 100644
--- a/drivers/net/failsafe/failsafe_ops.c
+++ b/drivers/net/failsafe/failsafe_ops.c
@@ -398,7 +398,8 @@ fs_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
if (rxq->event_fd >= 0)
close(rxq->event_fd);
FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
- if (ETH(sdev)->data->rx_queues != NULL &&
+ if (SUBOPS(sdev, rx_queue_release) != NULL &&
+ ETH(sdev)->data->rx_queues != NULL &&
ETH(sdev)->data->rx_queues[rxq->qid] != NULL)
SUBOPS(sdev, rx_queue_release)(ETH(sdev), rxq->qid);
}
@@ -574,7 +575,8 @@ fs_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
if (fs_lock(dev, 0) != 0)
return;
FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) {
- if (ETH(sdev)->data->tx_queues != NULL &&
+ if (SUBOPS(sdev, tx_queue_release) != NULL &&
+ ETH(sdev)->data->tx_queues != NULL &&
ETH(sdev)->data->tx_queues[txq->qid] != NULL)
SUBOPS(sdev, tx_queue_release)(ETH(sdev), txq->qid);
}
--
2.34.1