[v1,2/6] baseband/fpga_5gnr_fec: fix seg fault unconf queue

Message ID 20230523184818.139353-3-hernan.vargas@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series baseband/fpga_5gnr_fec: changes for 23.07 |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Vargas, Hernan May 23, 2023, 6:48 p.m. UTC
  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: stable@dpdk.org

Signed-off-by: Hernan Vargas <hernan.vargas@intel.com>
---
 drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Maxime Coquelin May 23, 2023, 7:28 p.m. UTC | #1
On 5/23/23 20:48, Hernan Vargas wrote:
> 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: stable@dpdk.org
> 
> Signed-off-by: Hernan Vargas <hernan.vargas@intel.com>
> ---
>   drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> 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 9388cce52960..a6211f73e6e3 100644
> --- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
> +++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
> @@ -573,6 +573,10 @@ fpga_queue_start(struct rte_bbdev *dev, uint16_t queue_id)
>   		return -1;
>   	}
>   #endif
> +	if (dev->data->queues[queue_id].queue_private == NULL) {
> +		rte_bbdev_log(ERR, "Cannot start invalid queue %d", queue_id);
> +		return -1;
> +	}
>   	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);

Same comment here for offset and q declarations, it should be at the top
of the function.

Maxime
  

Patch

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 9388cce52960..a6211f73e6e3 100644
--- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
+++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
@@ -573,6 +573,10 @@  fpga_queue_start(struct rte_bbdev *dev, uint16_t queue_id)
 		return -1;
 	}
 #endif
+	if (dev->data->queues[queue_id].queue_private == NULL) {
+		rte_bbdev_log(ERR, "Cannot start invalid queue %d", queue_id);
+		return -1;
+	}
 	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);