* [PATCH v2 1/6] baseband/fpga_5gnr_fec: fix possible div by zero
[not found] <20230525182812.152907-1-hernan.vargas@intel.com>
@ 2023-05-25 18:28 ` Hernan Vargas
2023-07-06 9:10 ` Maxime Coquelin
2023-07-06 9:10 ` Maxime Coquelin
2023-05-25 18:28 ` [PATCH v2 2/6] baseband/fpga_5gnr_fec: fix seg fault unconf queue Hernan Vargas
1 sibling, 2 replies; 4+ messages in thread
From: Hernan Vargas @ 2023-05-25 18:28 UTC (permalink / raw)
To: dev, maxime.coquelin, gakhil, trix
Cc: nicolas.chautru, qi.z.zhang, Hernan Vargas, stable
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>
Reviewed-by: Maxime Coquelin <maxime.coquelin@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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 2/6] baseband/fpga_5gnr_fec: fix seg fault unconf queue
[not found] <20230525182812.152907-1-hernan.vargas@intel.com>
2023-05-25 18:28 ` [PATCH v2 1/6] baseband/fpga_5gnr_fec: fix possible div by zero Hernan Vargas
@ 2023-05-25 18:28 ` Hernan Vargas
1 sibling, 0 replies; 4+ messages in thread
From: Hernan Vargas @ 2023-05-25 18:28 UTC (permalink / raw)
To: dev, maxime.coquelin, gakhil, trix
Cc: nicolas.chautru, qi.z.zhang, Hernan Vargas, stable
Adding exception to prevent segmentation fault in case a queue is
started which was not configured earlier.
Fixes: c58109a8871d ("baseband/fpga_5gnr_fec: add queue configuration")
Cc: stable@dpdk.org
Signed-off-by: Hernan Vargas <hernan.vargas@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
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 99390c48160c..6b0644ffc5d6 100644
--- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
+++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
@@ -567,17 +567,21 @@ static int
fpga_queue_start(struct rte_bbdev *dev, uint16_t queue_id)
{
struct fpga_5gnr_fec_device *d = dev->data->dev_private;
+ struct fpga_queue *q = dev->data->queues[queue_id].queue_private;
+ uint32_t offset = FPGA_5GNR_FEC_RING_CTRL_REGS +
+ (sizeof(struct fpga_ring_ctrl_reg) * q->q_idx);
+ uint8_t enable = 0x01;
+ uint16_t zero = 0x0000;
#ifdef RTE_LIBRTE_BBDEV_DEBUG
if (d == NULL) {
rte_bbdev_log(ERR, "Invalid device pointer");
return -1;
}
#endif
- struct fpga_queue *q = dev->data->queues[queue_id].queue_private;
- uint32_t offset = FPGA_5GNR_FEC_RING_CTRL_REGS +
- (sizeof(struct fpga_ring_ctrl_reg) * q->q_idx);
- uint8_t enable = 0x01;
- uint16_t zero = 0x0000;
+ if (dev->data->queues[queue_id].queue_private == NULL) {
+ rte_bbdev_log(ERR, "Cannot start invalid queue %d", queue_id);
+ return -1;
+ }
/* Clear queue head and tail variables */
q->tail = q->head_free_desc = 0;
--
2.37.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/6] baseband/fpga_5gnr_fec: fix possible div by zero
2023-05-25 18:28 ` [PATCH v2 1/6] baseband/fpga_5gnr_fec: fix possible div by zero Hernan Vargas
@ 2023-07-06 9:10 ` Maxime Coquelin
2023-07-06 9:10 ` Maxime Coquelin
1 sibling, 0 replies; 4+ messages in thread
From: Maxime Coquelin @ 2023-07-06 9:10 UTC (permalink / raw)
To: Hernan Vargas, dev, gakhil, trix; +Cc: nicolas.chautru, qi.z.zhang, stable
On 5/25/23 20:28, 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>
> Reviewed-by: Maxime Coquelin <maxime.coquelin@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;
Applied to dpdk-next-baseband/for-main.
Thanks,
Maxime
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/6] baseband/fpga_5gnr_fec: fix possible div by zero
2023-05-25 18:28 ` [PATCH v2 1/6] baseband/fpga_5gnr_fec: fix possible div by zero Hernan Vargas
2023-07-06 9:10 ` Maxime Coquelin
@ 2023-07-06 9:10 ` Maxime Coquelin
1 sibling, 0 replies; 4+ messages in thread
From: Maxime Coquelin @ 2023-07-06 9:10 UTC (permalink / raw)
To: Hernan Vargas, dev, gakhil, trix; +Cc: nicolas.chautru, qi.z.zhang, stable
On 5/25/23 20:28, 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>
> Reviewed-by: Maxime Coquelin <maxime.coquelin@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;
Applied to dpdk-next-baseband/for-main.
Thanks,
Maxime
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-07-06 9:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20230525182812.152907-1-hernan.vargas@intel.com>
2023-05-25 18:28 ` [PATCH v2 1/6] baseband/fpga_5gnr_fec: fix possible div by zero Hernan Vargas
2023-07-06 9:10 ` Maxime Coquelin
2023-07-06 9:10 ` Maxime Coquelin
2023-05-25 18:28 ` [PATCH v2 2/6] baseband/fpga_5gnr_fec: fix seg fault unconf queue Hernan Vargas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).