[PATCH v2 1/6] baseband/fpga_5gnr_fec: fix possible div by zero

Hernan Vargas hernan.vargas at intel.com
Thu May 25 20:28:07 CEST 2023


Add fix to have an early exit when z_c is zero to prevent a possible
division by zero.

Fixes: 44dc6faa796f ("baseband/fpga_5gnr_fec: add LDPC processing functions")
Cc: stable at dpdk.org

Signed-off-by: Hernan Vargas <hernan.vargas at intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
 drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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 f29565af8cca..99390c48160c 100644
--- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
+++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
@@ -877,9 +877,11 @@ check_desc_error(uint32_t error_code) {
 static inline uint16_t
 get_k0(uint16_t n_cb, uint16_t z_c, uint8_t bg, uint8_t rv_index)
 {
+	uint16_t n = (bg == 1 ? N_ZC_1 : N_ZC_2) * z_c;
 	if (rv_index == 0)
 		return 0;
-	uint16_t n = (bg == 1 ? N_ZC_1 : N_ZC_2) * z_c;
+	if (z_c == 0)
+		return 0;
 	if (n_cb == n) {
 		if (rv_index == 1)
 			return (bg == 1 ? K0_1_1 : K0_1_2) * z_c;
-- 
2.37.1



More information about the stable mailing list