Skip to content

Commit

Permalink
baseband/acc100: check turbo dec/enc input
Browse files Browse the repository at this point in the history
[ upstream commit 1d43b46 ]

Add NULL check for the turbo decoder and encoder input length.

Fixes: 3bfc5f6 ("baseband/acc100: add debug function to validate input")

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 da8a049 commit 257dd80
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions drivers/baseband/acc100/rte_acc100_pmd.c
Expand Up @@ -2086,6 +2086,11 @@ validate_enc_op(struct rte_bbdev_enc_op *op)
return -1;
}

if (unlikely(turbo_enc->input.length == 0)) {
rte_bbdev_log(ERR, "input length null");
return -1;
}

if (turbo_enc->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
tb = &turbo_enc->tb_params;
if ((tb->k_neg < RTE_BBDEV_TURBO_MIN_CB_SIZE
Expand All @@ -2105,11 +2110,12 @@ validate_enc_op(struct rte_bbdev_enc_op *op)
RTE_BBDEV_TURBO_MAX_CB_SIZE);
return -1;
}
if (tb->c_neg > (RTE_BBDEV_TURBO_MAX_CODE_BLOCKS - 1))
if (unlikely(tb->c_neg > 0)) {
rte_bbdev_log(ERR,
"c_neg (%u) is out of range 0 <= value <= %u",
tb->c_neg,
RTE_BBDEV_TURBO_MAX_CODE_BLOCKS - 1);
"c_neg (%u) expected to be null",
tb->c_neg);
return -1;
}
if (tb->c < 1 || tb->c > RTE_BBDEV_TURBO_MAX_CODE_BLOCKS) {
rte_bbdev_log(ERR,
"c (%u) is out of range 1 <= value <= %u",
Expand Down Expand Up @@ -2601,6 +2607,11 @@ validate_dec_op(struct rte_bbdev_dec_op *op)
return -1;
}

if (unlikely(turbo_dec->input.length == 0)) {
rte_bbdev_log(ERR, "input length null");
return -1;
}

if (turbo_dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
tb = &turbo_dec->tb_params;
if ((tb->k_neg < RTE_BBDEV_TURBO_MIN_CB_SIZE
Expand All @@ -2621,11 +2632,13 @@ validate_dec_op(struct rte_bbdev_dec_op *op)
RTE_BBDEV_TURBO_MAX_CB_SIZE);
return -1;
}
if (tb->c_neg > (RTE_BBDEV_TURBO_MAX_CODE_BLOCKS - 1))
if (unlikely(tb->c_neg > (RTE_BBDEV_TURBO_MAX_CODE_BLOCKS - 1))) {
rte_bbdev_log(ERR,
"c_neg (%u) is out of range 0 <= value <= %u",
tb->c_neg,
RTE_BBDEV_TURBO_MAX_CODE_BLOCKS - 1);
return -1;
}
if (tb->c < 1 || tb->c > RTE_BBDEV_TURBO_MAX_CODE_BLOCKS) {
rte_bbdev_log(ERR,
"c (%u) is out of range 1 <= value <= %u",
Expand Down

0 comments on commit 257dd80

Please sign in to comment.