[v3,2/8] ml/cnxk: fix potential division by zero
Checks
Commit Message
Fix division or modulo by zero issue reported by coverity. Added
a check to count, before updating average value of a stat.
Coverity issue: 383658
Fixes: 4ff4ab8e1a20 ("ml/cnxk: support extended statistics")
Signed-off-by: Srikanth Yalavarthi <syalavarthi@marvell.com>
---
drivers/ml/cnxk/cn10k_ml_ops.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
@@ -444,7 +444,8 @@ cn10k_ml_prep_fp_job_descriptor(struct rte_ml_dev *dev, struct cn10k_ml_req *req
count += model->burst_stats[qp_id].dequeued_count - \
model->burst_stats[qp_id].str##_reset_count; \
} \
- value = value / count; \
+ if (count != 0) \
+ value = value / count; \
} while (0)
#define ML_MIN_FOREACH_QP(dev, model, qp_id, str, value, count) \