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 56A6641EB5; Thu, 16 Mar 2023 22:30:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D286F42F9E; Thu, 16 Mar 2023 22:29:44 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id CDEBD42DB7 for ; Thu, 16 Mar 2023 22:29:38 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32GFtBbc005959 for ; Thu, 16 Mar 2023 14:29:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=nFfZAVDEbWV9RGMr4gW5TJQhHU1ytYll04vb8l6RUKg=; b=YHNgNWX1+dNwUwWIR9swvX+6W2man5nEj+MUZSdExweyKhFqoIjaI5OaBxEGHmUCRY+Y A+nEFU8SSEvztFvsv4doSs7v/hG0mfFvxfpf9ymQQQTUeBdWB5U2KZblSAaQWHkanyHq R4gs+/nozzZ8Iccsh/kvpAY5cEZ0ONLZAm5PC0P7ZP5DfQSQP0whB7bmzEzmLnKkUKCy Av+c1lEoVIJUF9V/OMX0wyFm9X2dFmQtX2ASpYakKy8DQVGVwrSSVn3P/hzZhob1nk+d bde7SXGT+552T9E8vEvSzKr/55yYTaYkAZuEWRYOTyGPA5bLRJRde8jMThGDxLg8MOpO Uw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3pbxq2ucrk-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 16 Mar 2023 14:29:37 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 16 Mar 2023 14:29:35 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Thu, 16 Mar 2023 14:29:35 -0700 Received: from ml-host-33.caveonetworks.com (unknown [10.110.143.233]) by maili.marvell.com (Postfix) with ESMTP id 68F0F3F707C; Thu, 16 Mar 2023 14:29:35 -0700 (PDT) From: Srikanth Yalavarthi To: Srikanth Yalavarthi , Prince Takkar CC: , , , Subject: [PATCH v3 2/8] ml/cnxk: fix potential division by zero Date: Thu, 16 Mar 2023 14:28:58 -0700 Message-ID: <20230316212904.9318-3-syalavarthi@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230316212904.9318-1-syalavarthi@marvell.com> References: <20230315135427.11489-1-syalavarthi@marvell.com> <20230316212904.9318-1-syalavarthi@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: Zb4guDoiBOZYeB1KsfltgAk3sfPWY5M5 X-Proofpoint-ORIG-GUID: Zb4guDoiBOZYeB1KsfltgAk3sfPWY5M5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-16_14,2023-03-16_02,2023-02-09_01 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 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 --- drivers/ml/cnxk/cn10k_ml_ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/ml/cnxk/cn10k_ml_ops.c b/drivers/ml/cnxk/cn10k_ml_ops.c index 7d5eb97668..bf9409ad10 100644 --- a/drivers/ml/cnxk/cn10k_ml_ops.c +++ b/drivers/ml/cnxk/cn10k_ml_ops.c @@ -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) \ -- 2.17.1