[v7,2/6] baseband/acc100: add protection for some negative scenario

Message ID 1654036307-182860-3-git-send-email-nicolas.chautru@intel.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series drivers/baseband: PMD to support ACC100/ACC101 devices |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chautru, Nicolas May 31, 2022, 10:31 p.m. UTC
  Catch exception in PMD in case of invalid input parameter.

Fixes: 5ad5060f8f7a ("baseband/acc100: add LDPC processing functions")
Cc: stable@dpdk.org

Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
---
 drivers/baseband/acc100/rte_acc100_pmd.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

Maxime Coquelin June 2, 2022, 8:21 a.m. UTC | #1
On 6/1/22 00:31, Nicolas Chautru wrote:
> Catch exception in PMD in case of invalid input parameter.
> 
> Fixes: 5ad5060f8f7a ("baseband/acc100: add LDPC processing functions")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
> ---
>   drivers/baseband/acc100/rte_acc100_pmd.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/baseband/acc100/rte_acc100_pmd.c b/drivers/baseband/acc100/rte_acc100_pmd.c
> index 79bee43..32c8bc2 100644
> --- a/drivers/baseband/acc100/rte_acc100_pmd.c
> +++ b/drivers/baseband/acc100/rte_acc100_pmd.c
> @@ -1236,6 +1236,8 @@
>   			return (bg == 1 ? ACC100_K0_3_1 : ACC100_K0_3_2) * z_c;
>   	}
>   	/* LBRM case - includes a division by N */
> +	if (unlikely(z_c == 0))
> +		return 0;
>   	if (rv_index == 1)
>   		return (((bg == 1 ? ACC100_K0_1_1 : ACC100_K0_1_2) * n_cb)
>   				/ n) * z_c;
> @@ -1764,6 +1766,10 @@
>   
>   	/* Soft output */
>   	if (check_bit(op->turbo_dec.op_flags, RTE_BBDEV_TURBO_SOFT_OUTPUT)) {
> +		if (op->turbo_dec.soft_output.data == 0) {
> +			rte_bbdev_log(ERR, "Soft output is not defined");
> +			return -1;
> +		}
>   		if (check_bit(op->turbo_dec.op_flags,
>   				RTE_BBDEV_TURBO_EQUALIZER))
>   			*s_out_length = e;

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  

Patch

diff --git a/drivers/baseband/acc100/rte_acc100_pmd.c b/drivers/baseband/acc100/rte_acc100_pmd.c
index 79bee43..32c8bc2 100644
--- a/drivers/baseband/acc100/rte_acc100_pmd.c
+++ b/drivers/baseband/acc100/rte_acc100_pmd.c
@@ -1236,6 +1236,8 @@ 
 			return (bg == 1 ? ACC100_K0_3_1 : ACC100_K0_3_2) * z_c;
 	}
 	/* LBRM case - includes a division by N */
+	if (unlikely(z_c == 0))
+		return 0;
 	if (rv_index == 1)
 		return (((bg == 1 ? ACC100_K0_1_1 : ACC100_K0_1_2) * n_cb)
 				/ n) * z_c;
@@ -1764,6 +1766,10 @@ 
 
 	/* Soft output */
 	if (check_bit(op->turbo_dec.op_flags, RTE_BBDEV_TURBO_SOFT_OUTPUT)) {
+		if (op->turbo_dec.soft_output.data == 0) {
+			rte_bbdev_log(ERR, "Soft output is not defined");
+			return -1;
+		}
 		if (check_bit(op->turbo_dec.op_flags,
 				RTE_BBDEV_TURBO_EQUALIZER))
 			*s_out_length = e;