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 0F2CCA0C43; Fri, 22 Oct 2021 17:48:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0CDBE4121B; Fri, 22 Oct 2021 17:48:14 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2075.outbound.protection.outlook.com [40.107.220.75]) by mails.dpdk.org (Postfix) with ESMTP id 10F2C41215 for ; Fri, 22 Oct 2021 17:48:10 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aZoyAV2uNeEjO3/F/wsOJjpZH2ka9khigOqp+k8iOToe6gAJ/9rrhYpS3ztC0XxFcOsjYeJX4daL2kucekAYsDk7c7EenhKhO+vuvgKJeHCkHAgcSP2Wa3aSH1HBb2c8QqVK5W7w68Z95vQQVDICnooRxIaqsOZHdLEuVcqLh8YKhNpuEaXGB1eXihGIxZGdkGXmd1u0pDS2AdIo+n/+DPShlvXScHR8vWYDMm9i7752p7S3l4h+VmLR0hdMYbhID7ZoyUjjcUa5UV4voMcnsP9vbJJcGqfu+hc+SltpfXnaA9a/7sjL/bQPBI87wsS72xQqFl3GUq4epgHMz5WWqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=k/4VVQj+4KeA3wUVnKh9UmF4rUy9BKPjiIqqixmfKPM=; b=B2D5xBLsmgQhOL8Z+dbMfUI84y8jlbu0cqzJu9pxTkLxWny08lV31KKQ73HQHXY4hGQ53NjLbKZbc3y68Qodi0ToAnB32dSVm1tLQ7n30t5BD2ME8t0tSO/QDJuzum4nkZ35jifJmOHp5ZX2jCA8v2ubQ0V0S3wNbKmqB1b9DKdj6Fyao1C2N09/yi529ROMDzU/DfumtqjrIW4b9EhtibtTwkz8DCCC/Ae7YuhGW3AEJw/HMOGQk2JtEQcBbb/mD2fNe7BIr4ZQV3cPmkTUjzK6VIEn5Y0LrRqkdOyIYbH8dUzJPKZ/sm43+05G1SCJ62iDup7d0leJPZ8y9VL7BQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=gmail.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k/4VVQj+4KeA3wUVnKh9UmF4rUy9BKPjiIqqixmfKPM=; b=VYxMThTV7ja7r3WOltAFtt1jikVnj2P+SL3+IZI3n3rVZz81PpyGKxpqB02E/w7ucE5gXZTlaPHCxlKqwBamXS8DX9Mm61OkL8zoaU9gfjzCWsKFVpuOHDE10M+o6ilfSxmDZ2NLjDsm2Yr5GuCx9G4YuPwe01Y2kAcFaLCc4dRgLtUD5chklG6/FE3kkPB+Dt7wfI6FfACAc9l4jHk4I0uPT2ZoCloFLXNoDCkUUemXuG1JR8zlMFp2pPB9LI3Obj52nA3XJ6N9ZUn4DadHi7i09novpHBjVJCUPNOTIeTm5GOYkIaZfVD3ujOTEgEGezRoDEyFAYCDhur1VHrxQg== Received: from DM6PR07CA0067.namprd07.prod.outlook.com (2603:10b6:5:74::44) by SA0PR12MB4560.namprd12.prod.outlook.com (2603:10b6:806:97::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.18; Fri, 22 Oct 2021 15:48:08 +0000 Received: from DM6NAM11FT053.eop-nam11.prod.protection.outlook.com (2603:10b6:5:74:cafe::1c) by DM6PR07CA0067.outlook.office365.com (2603:10b6:5:74::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 15:48:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT053.mail.protection.outlook.com (10.13.173.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4628.16 via Frontend Transport; Fri, 22 Oct 2021 15:48:07 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 22 Oct 2021 15:48:05 +0000 From: Francis Kelly To: , Ori Kam CC: , , , Ady Agbarih Date: Fri, 22 Oct 2021 15:45:58 +0000 Message-ID: <20211022154600.2180938-8-fkelly@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022154600.2180938-1-fkelly@nvidia.com> References: <20211022154600.2180938-1-fkelly@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18544722-0437-4f1e-093a-08d9957357f4 X-MS-TrafficTypeDiagnostic: SA0PR12MB4560: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n55g8yZt7ab/pe96VN0y5YjDD0Suw6CQjS7GFKaNfqsAFo4Nd+jKgq3QPO4806ca+c6BdWR0vBVhr2PMDz8X26td83dEtY4VvAI8jM3BUlwpmVT/k9mWicvOXZsJ/KuQ6AqsPtjkDMFnKAzVpuOA3cl6qJHaXCmKGEVERonwNG78/0Y5Rg9rxuPUxOO/HjK+Fq/OB4JW8uTh3kF2b3i1bCpRyaLHeKDFmGsmumDhbQBy3g88WCOW0K6fY7L5FH4FqR2z+Y0AtAciV/aHBjNmokH8oQMsGubln2qxVSxcMSNBwX54YPR2TT27wpPcPWKvNA1hsL0hbVR8e5q/uF17DJizGjcSpe8TgL8FoH13s9i16Kbi+o5n3GgPPVFol1IKAebhnhVOkZnw783j8fLp6Y6O3WbeedtBXUY9N/oCn8UEClworu3ZCjE5QSEmvTtMNAcwh3Q6aBM2XH2DXM8O//RJYEMjEO5HCEUbgGws8PhCsts9t28uaNRDk/CFCqPxyzk9Pqucz1KJgLCbQPHoBwk3+Fpw4e35aa/LkpEAGaN1eu36pBE+1Ocl+bXCakWWrnZSavVXaxWmJZi9yWooLEHTmqCZ6Z4rlru28YWDVtuJYbpQwUFaFG7XtJTQdczpyC85Q3z0dvWWqUpIwpFiB5wEe+awVYSG8nCDfFwZ/sAbkLUKQPXEyI55PX1lRKhBj3Vjd+F0OPUlxLm3fs8ndg== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(110136005)(54906003)(1076003)(70586007)(70206006)(82310400003)(4326008)(8936002)(426003)(336012)(26005)(7636003)(86362001)(16526019)(47076005)(7696005)(5660300002)(186003)(36860700001)(36756003)(356005)(55016002)(36906005)(2906002)(316002)(6286002)(83380400001)(6666004)(6636002)(2616005)(508600001)(8676002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2021 15:48:07.7975 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18544722-0437-4f1e-093a-08d9957357f4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT053.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4560 Subject: [dpdk-dev] [PATCH 08/10] regex/mlx5: fix uninitialized QP destroy 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 Sender: "dev" From: Ady Agbarih The number of QPs for a device are setup during the configuration phase, when the user calls rte_regexdev_configure(). The mlx5 regex driver then pre-allocates QPs, however those QPs are not setup/ready for sending jobs. The user has to configure each QP using rte_regexdev_queue_pair_setup(). When stopping the device the driver destroys all QPs that were preallocated assuming that they are all setup. This results in an attempt to destroy an uninitialized QP, leading to a NULL dereference error. In order to solve this issue we first check that the QP jobs array has been initialized before attempting to destroy the QP. Fixes: 35f8f6c8dbee ("regex/mlx5: add cleanup code") Cc: orika@nvidia.com Signed-off-by: Ady Agbarih --- drivers/regex/mlx5/mlx5_regex_control.c | 3 +++ drivers/regex/mlx5/mlx5_regex_fastpath.c | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/regex/mlx5/mlx5_regex_control.c b/drivers/regex/mlx5/mlx5_regex_control.c index 3e0a0cdd71..52f66ecce8 100644 --- a/drivers/regex/mlx5/mlx5_regex_control.c +++ b/drivers/regex/mlx5/mlx5_regex_control.c @@ -283,6 +283,9 @@ mlx5_regex_clean_ctrl(struct rte_regexdev *dev) return; for (qp_ind = 0; qp_ind < priv->nb_queues; qp_ind++) { qp = &priv->qps[qp_ind]; + /* Check if mlx5_regex_qp_setup() was called for this QP */ + if (!qp->jobs) + continue; mlx5_regexdev_teardown_fastpath(priv, qp_ind); mlx5_mr_btree_free(&qp->mr_ctrl.cache_bh); for (i = 0; i < qp->nb_obj; i++) diff --git a/drivers/regex/mlx5/mlx5_regex_fastpath.c b/drivers/regex/mlx5/mlx5_regex_fastpath.c index 0833b2817e..26b4cc5c82 100644 --- a/drivers/regex/mlx5/mlx5_regex_fastpath.c +++ b/drivers/regex/mlx5/mlx5_regex_fastpath.c @@ -739,6 +739,7 @@ mlx5_regexdev_setup_fastpath(struct mlx5_regex_priv *priv, uint32_t qp_id) err = setup_buffers(priv, qp); if (err) { rte_free(qp->jobs); + qp->jobs = NULL; return err; } @@ -791,14 +792,14 @@ mlx5_regexdev_teardown_fastpath(struct mlx5_regex_priv *priv, uint32_t qp_id) struct mlx5_regex_qp *qp = &priv->qps[qp_id]; uint32_t i; - if (qp) { + if (qp->jobs) { for (i = 0; i < qp->nb_desc; i++) { if (qp->jobs[i].imkey) claim_zero(mlx5_devx_cmd_destroy (qp->jobs[i].imkey)); } free_buffers(qp); - if (qp->jobs) - rte_free(qp->jobs); + rte_free(qp->jobs); + qp->jobs = NULL; } } -- 2.25.1