Adding exception to prevent segmentation fault in case a queue is
started which was not configured earlier.

Fixes: c58109a8871d ("baseband/fpga_5gnr_fec: add queue configuration")
Cc: [email protected]

Signed-off-by: Hernan Vargas <[email protected]>
Reviewed-by: Maxime Coquelin <[email protected]>
---
 drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c 
b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
index 99390c48160c..6b0644ffc5d6 100644
--- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
+++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
@@ -567,17 +567,21 @@ static int
 fpga_queue_start(struct rte_bbdev *dev, uint16_t queue_id)
 {
        struct fpga_5gnr_fec_device *d = dev->data->dev_private;
+       struct fpga_queue *q = dev->data->queues[queue_id].queue_private;
+       uint32_t offset = FPGA_5GNR_FEC_RING_CTRL_REGS +
+                       (sizeof(struct fpga_ring_ctrl_reg) * q->q_idx);
+       uint8_t enable = 0x01;
+       uint16_t zero = 0x0000;
 #ifdef RTE_LIBRTE_BBDEV_DEBUG
        if (d == NULL) {
                rte_bbdev_log(ERR, "Invalid device pointer");
                return -1;
        }
 #endif
-       struct fpga_queue *q = dev->data->queues[queue_id].queue_private;
-       uint32_t offset = FPGA_5GNR_FEC_RING_CTRL_REGS +
-                       (sizeof(struct fpga_ring_ctrl_reg) * q->q_idx);
-       uint8_t enable = 0x01;
-       uint16_t zero = 0x0000;
+       if (dev->data->queues[queue_id].queue_private == NULL) {
+               rte_bbdev_log(ERR, "Cannot start invalid queue %d", queue_id);
+               return -1;
+       }
 
        /* Clear queue head and tail variables */
        q->tail = q->head_free_desc = 0;
-- 
2.37.1

Reply via email to