[v1,1/6] baseband/fpga_5gnr_fec: fix possible div by zero
Checks
Commit Message
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@dpdk.org
Signed-off-by: Hernan Vargas <hernan.vargas@intel.com>
---
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 2 ++
1 file changed, 2 insertions(+)
Comments
On 5/23/23 20:48, Hernan Vargas wrote:
> 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@dpdk.org
>
> Signed-off-by: Hernan Vargas <hernan.vargas@intel.com>
> ---
> drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 2 ++
> 1 file changed, 2 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 f29565af8cca..9388cce52960 100644
> --- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
> +++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
> @@ -879,6 +879,8 @@ get_k0(uint16_t n_cb, uint16_t z_c, uint8_t bg, uint8_t rv_index)
> {
> if (rv_index == 0)
> return 0;
> + if (z_c == 0)
> + return 0;
> uint16_t n = (bg == 1 ? N_ZC_1 : N_ZC_2) * z_c;
You could take the opportunity to move n declaration at the top of the
function.
We this done, feel free to add:
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thanks,
Maxime
> if (n_cb == n) {
> if (rv_index == 1)
@@ -879,6 +879,8 @@ get_k0(uint16_t n_cb, uint16_t z_c, uint8_t bg, uint8_t rv_index)
{
if (rv_index == 0)
return 0;
+ if (z_c == 0)
+ return 0;
uint16_t n = (bg == 1 ? N_ZC_1 : N_ZC_2) * z_c;
if (n_cb == n) {
if (rv_index == 1)