From patchwork Tue May 31 12:19:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanumanth Pothula X-Patchwork-Id: 112145 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 79E5CA0547; Tue, 31 May 2022 14:20:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1E420400EF; Tue, 31 May 2022 14:20:31 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id E2ABF400D6 for ; Tue, 31 May 2022 14:20:29 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24VBm87R032206 for ; Tue, 31 May 2022 05:20:28 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=jVu+EGzs0Vb0TNQ4H6cUuK6n40zBy/LVokY/1+YRvjA=; b=KsWeszsTlLRxXzdOO9H7PcahXQWPPotZhqNxKxbgdglDWouxOFfyTd0oC1wFOwZ5+1nq iKX2wL4iqdA7pdLW3KWlqiUK2j0XD5BlSs9q81M79FBQDik6VE7FmlxkvTqAS0kC/j/8 jUuLmkzv9lNmkAVJIY+VDR1B5woKreBf0jHz5ljAAfDJYTPPcx4pRedryqHPkQlrAzi/ f0L15Ln5zNZn0iJBJZ8QgAzy1p47dyOcvr2u+GcvHsRmwO6tdi7wusqSeWTqCN3u66Hb JSBqR+jJxn41XnARAjfpzpQs6rGWnnxffCVoM0CVm7aR63F6u+wpc+ZoUj3G6Mko3tid 1A== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3gbh3phfnt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 31 May 2022 05:20:27 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 31 May 2022 05:20:26 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 31 May 2022 05:20:26 -0700 Received: from localhost.localdomain (unknown [10.28.48.102]) by maili.marvell.com (Postfix) with ESMTP id 511E43F7040; Tue, 31 May 2022 05:20:24 -0700 (PDT) From: Hanumanth Pothula To: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao CC: , , Hanumanth Pothula Subject: [PATCH] common/cnxk: add lower bound check for SSO resources Date: Tue, 31 May 2022 17:49:50 +0530 Message-ID: <20220531121950.3511727-1-hpothula@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Proofpoint-GUID: OmZnOKpmHAycSE_a5bi8TAQkFAW3SgVr X-Proofpoint-ORIG-GUID: OmZnOKpmHAycSE_a5bi8TAQkFAW3SgVr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-05-31_04,2022-05-30_03,2022-02-23_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 Observing a crash when the user runs the second test case, with the first test case using all HWGRP and HWS, SSO resources. This happens as there are no HWGRP and HWS resources left for the second test case. Make sure to process a test case only when valid HWGRPS and HWS are present by adding lower bound check for HWGRPS and HWS. Signed-off-by: Hanumanth Pothula --- drivers/common/cnxk/roc_sso.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/common/cnxk/roc_sso.c b/drivers/common/cnxk/roc_sso.c index f8a0a96533..8997e6f999 100644 --- a/drivers/common/cnxk/roc_sso.c +++ b/drivers/common/cnxk/roc_sso.c @@ -598,9 +598,9 @@ roc_sso_rsrc_init(struct roc_sso *roc_sso, uint8_t nb_hws, uint16_t nb_hwgrp) struct sso_lf_alloc_rsp *rsp_hwgrp; int rc; - if (roc_sso->max_hwgrp < nb_hwgrp) + if (!nb_hwgrp || roc_sso->max_hwgrp < nb_hwgrp) return -ENOENT; - if (roc_sso->max_hws < nb_hws) + if (!nb_hws || roc_sso->max_hws < nb_hws) return -ENOENT; rc = sso_rsrc_attach(roc_sso, SSO_LF_TYPE_HWS, nb_hws);