From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A040242B83; Tue, 23 May 2023 21:27:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8EEE140EF0; Tue, 23 May 2023 21:27:06 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 8B7D540EF0 for ; Tue, 23 May 2023 21:27:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684870024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m3vQC8EEu421TyCWlZMJ5wsPY7bAWLOu+GxZIqc2cL0=; b=esbrd6bSZwLGigpuB5YxCHK7Dx99cQ9uAtgyu67L11VITSO6ObGcqQBg+GRzDY25QF2POO UCfgHDVX91yD0K54rfKZ56v9G8BdCNPFIJQV+KTOpiV2PS4Fu4A2KyKFZ5BOO4NKtt/RfS RWCTteWDL4ZSRD6OS+LAb40T9Sigm28= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-670-jtXcMEyXM_mrZSD03k2-rQ-1; Tue, 23 May 2023 15:27:00 -0400 X-MC-Unique: jtXcMEyXM_mrZSD03k2-rQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5681A8032F5; Tue, 23 May 2023 19:27:00 +0000 (UTC) Received: from [10.39.208.2] (unknown [10.39.208.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E62CF2166B25; Tue, 23 May 2023 19:26:58 +0000 (UTC) Message-ID: <7f019233-69cd-564f-6b03-90fa8455ec39@redhat.com> Date: Tue, 23 May 2023 21:26:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v1 1/6] baseband/fpga_5gnr_fec: fix possible div by zero To: Hernan Vargas , dev@dpdk.org, gakhil@marvell.com, trix@redhat.com Cc: nicolas.chautru@intel.com, qi.z.zhang@intel.com, stable@dpdk.org References: <20230523184818.139353-1-hernan.vargas@intel.com> <20230523184818.139353-2-hernan.vargas@intel.com> From: Maxime Coquelin In-Reply-To: <20230523184818.139353-2-hernan.vargas@intel.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 > --- > 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 Thanks, Maxime > if (n_cb == n) { > if (rv_index == 1)