Skip to content

Commit

Permalink
baseband/acc100: add null checks
Browse files Browse the repository at this point in the history
[ upstream commit 4a2f231 ]

Add unlikely checks for NULL operation values.

Fixes: f404dfe ("baseband/acc100: support 4G processing")

Signed-off-by: Hernan Vargas <hernan.vargas@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
  • Loading branch information
Hernanlv authored and kevintraynor committed Nov 7, 2022
1 parent 257dd80 commit 4fb74af
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/baseband/acc100/rte_acc100_pmd.c
Expand Up @@ -2502,6 +2502,10 @@ enqueue_enc_one_op_tb(struct acc100_queue *q, struct rte_bbdev_enc_op *op,
r = op->turbo_enc.tb_params.r;

while (mbuf_total_left > 0 && r < c) {
if (unlikely(input == NULL)) {
rte_bbdev_log(ERR, "Not enough input segment");
return -EINVAL;
}
seg_total_left = rte_pktmbuf_data_len(input) - in_offset;
/* Set up DMA descriptor */
desc = q->ring_addr + ((q->sw_ring_head + total_enqueued_cbs)
Expand Down Expand Up @@ -3533,6 +3537,8 @@ acc100_enqueue_ldpc_dec_tb(struct rte_bbdev_queue_data *q_data,
break;
enqueued_cbs += ret;
}
if (unlikely(enqueued_cbs == 0))
return 0; /* Nothing to enqueue */

acc100_dma_enqueue(q, enqueued_cbs, &q_data->queue_stats);

Expand Down Expand Up @@ -4075,6 +4081,8 @@ acc100_dequeue_dec(struct rte_bbdev_queue_data *q_data,
for (i = 0; i < dequeue_num; ++i) {
op = (q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
& q->sw_ring_wrap_mask))->req.op_addr;
if (unlikely(op == NULL))
break;
if (op->turbo_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
ret = dequeue_dec_one_op_tb(q, &ops[i], dequeued_cbs,
&aq_dequeued);
Expand Down Expand Up @@ -4120,6 +4128,8 @@ acc100_dequeue_ldpc_dec(struct rte_bbdev_queue_data *q_data,
for (i = 0; i < dequeue_num; ++i) {
op = (q->ring_addr + ((q->sw_ring_tail + dequeued_cbs)
& q->sw_ring_wrap_mask))->req.op_addr;
if (unlikely(op == NULL))
break;
if (op->ldpc_dec.code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK)
ret = dequeue_dec_one_op_tb(q, &ops[i], dequeued_cbs,
&aq_dequeued);
Expand Down

0 comments on commit 4fb74af

Please sign in to comment.