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 80913A0C45; Thu, 25 Nov 2021 15:53:16 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 684C44271D; Thu, 25 Nov 2021 15:53:16 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2073.outbound.protection.outlook.com [40.107.243.73]) by mails.dpdk.org (Postfix) with ESMTP id EDC1B4271F for ; Thu, 25 Nov 2021 15:53:12 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NmZbPEHzZJRF0lohjNvUscPcxNx5yCjzPxhzMywGgIyYgIpLnWtLZ1r40uqpvtA32mYv+dqv86Yh5Nt9OdPs27g7kb+bR/sWzPUSmGiqdAO8WM2gQC8bYBEix7GaBX64xi8lW+yx1o1c8O+i2IM4dNMm1t447/dc7363EKhKUe3UTj6bmmiAdMkVA0H75804TzvaI04IsAoZ9QonzUturpnPEs3oU7jSooEXxkCNOs86i2RKuVvgaElZbDwzAt+jf2/nwPIXYfn1HRgz2E0sLaf8uU0WvUxmsIjpWwBSHi9QzF+wrtD7xevcYI59ihYmvBcD3FtXXu7abkLwqxX4Ow== 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=K9mAo9SbXT2OmD3sOpu3U6LUBVBYL/JBCvT06QxOVLk=; b=OhdwfVUvDWNtOF73oKlwn333iob1bjCWfuYFCOPuaZFijlBEX371d/vpw7LjLJsfJUTEhJ5ElRE6nSF5VqioSP6arXpgcfqtS0cVoQiLfEb7p4ASB1oUkQaqgyd8Wjh6aCD1MIFczjmHw44YxHlPv9FYcQe9hCgcXulgLInfFk25c3fciwb4VVoo6ZCtJhqXdEOGtTOZghJJF20t+PPcvPmBGlgkYu7cNmCeg1YcLsZvFbj4jLuVVN2lPtOjBqA0yCcOLAYAteZxLim0sLFI2cYu3qgmfw5GQAi6Vjj81zNf2RRuzhMDUev6yd/QFuYP6iH6js9I7FDe4r3S7WV9AA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org 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=K9mAo9SbXT2OmD3sOpu3U6LUBVBYL/JBCvT06QxOVLk=; b=EuOaiG2xsFnSqy4t4uwF4r7pPBWxt4euvXPeVm6h5gBBXTsEXW8jUHrKagCQugWoCJVS8GtZeJXYRytLQgJHDBs7cP2ha5dxqzkgiPqv1yE0tzKYUj81caA710bCylSc/e3il3Eoum22yLrivp187y8OYpIftI9YLuvzXY5yvciZJGS3g03weqZ2ZnyQkyiQECIMIG7Bi81Y+iCJOwc5cjsssFnt5+816hq3QAFUItuqZnqXUKqGM5hExEt68h+FOL5dCfCHHJUCa57o3+M3XMg/q1A1gRRgKEaN0T5k2n4UqwbsiQiV2y+N50ThGxpzUIN7q/qDmGhcha/d+5ipQw== Received: from BN9PR03CA0285.namprd03.prod.outlook.com (2603:10b6:408:f5::20) by BL1PR12MB5077.namprd12.prod.outlook.com (2603:10b6:208:310::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.24; Thu, 25 Nov 2021 14:53:11 +0000 Received: from BN8NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f5:cafe::cb) by BN9PR03CA0285.outlook.office365.com (2603:10b6:408:f5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.25 via Frontend Transport; Thu, 25 Nov 2021 14:53:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;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 BN8NAM11FT018.mail.protection.outlook.com (10.13.176.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4734.22 via Frontend Transport; Thu, 25 Nov 2021 14:53:10 +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; Thu, 25 Nov 2021 14:53:09 +0000 From: To: CC: Elena Agostini Subject: [PATCH v3] app/test-gpudev: remove all memory leaks Date: Thu, 25 Nov 2021 23:03:32 +0000 Message-ID: <20211125230332.15709-1-eagostini@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211117204453.27337-1-eagostini@nvidia.com> References: <20211117204453.27337-1-eagostini@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 20ce8772-1eaf-418b-5baf-08d9b0234ce2 X-MS-TrafficTypeDiagnostic: BL1PR12MB5077: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:67; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H4iEy5guIqvIWOX4F7AajTcfEgnSVFc5CXgQU4FciZpLaAM1710bdE4vyRXwOl2KvvlJB50YcIr1sV+3Y1zp0EzQuwrgbTaSrpCohYOLn72SVZ/76lnOVHtAo/OnkGVKcduoDrkruARwbvS6riuTM6mxDSxWVs//zUeftlm7rPgecU+KGX9H3RlmRGhy0stB6LslE/i0cToOcv1XpMaoJ4h5l48L79sPF93NGdrRYL4/RS0dHnMtkH37KH34w+covoUDOvKeV7mBzsph0NNt+JJ8nGOrkJXqd+gz3aKCORurEqWhI73ZgBBRUnT3nEZBBkC17leSIPqOTMjitQp7Ql9ran3iF06CfOq6tUN8bMskhON8D4ZSfD/tjoL24FstzRMSUiXFw4iaNroDLnSLOa456HcOIvbwscy/zLwYbESnzoSwkBnGQNpILlE0o+9tjdpwXL0W5oGN6XCsMyArQXgDfHfyWtTaCX//4DPGGsDEwzt/x6XFW4Ajak1ywQilP41Idqm0RrmYHR9aYfaL6oC24tsh4pcp0bU3I9m6EvvETFtdVffSkkEoHJrq4IQo4mvfYPz99TQC8qG8ZYkbn6F0JeM5vzhi0kOLpIvRJ0ufD+Imev7C36Cf2Ssb7Fh2o9SKXxjLOF/zoZb1F/CH6GXHX5toc9R9gF+nsiU0YjFOn/U03ZEU3p0AFNivBAx4L+sVTS/eUYCMdCt2Conp6w== 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)(4326008)(5660300002)(26005)(82310400004)(2876002)(107886003)(336012)(55016003)(186003)(2616005)(83380400001)(426003)(16526019)(36756003)(36860700001)(316002)(6286002)(508600001)(8936002)(70586007)(70206006)(6666004)(356005)(2906002)(6916009)(7636003)(1076003)(7696005)(86362001)(8676002)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Nov 2021 14:53:10.5540 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20ce8772-1eaf-418b-5baf-08d9b0234ce2 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: BN8NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5077 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 From: Elena Agostini Remove all memory leaks in case of errors in test-gpudev application. Fixes: e818c4e2bf50 ("gpudev: add memory API") Fixes: c7ebd65c1372 ("gpudev: add communication list") Signed-off-by: Elena Agostini --- app/test-gpudev/main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/test-gpudev/main.c b/app/test-gpudev/main.c index c647e30de4..5c1aa3d52f 100644 --- a/app/test-gpudev/main.c +++ b/app/test-gpudev/main.c @@ -117,6 +117,10 @@ alloc_gpu_memory(uint16_t gpu_id) return 0; error: + + rte_gpu_mem_free(gpu_id, ptr_1); + rte_gpu_mem_free(gpu_id, ptr_2); + printf("\n=======> TEST: FAILED\n"); return -1; } @@ -161,10 +165,15 @@ register_cpu_memory(uint16_t gpu_id) } printf("CPU memory 0x%p unregistered\n", ptr); + rte_free(ptr); + printf("\n=======> TEST: PASSED\n"); return 0; error: + + rte_gpu_mem_unregister(gpu_id, ptr); + rte_free(ptr); printf("\n=======> TEST: FAILED\n"); return -1; } @@ -227,6 +236,8 @@ create_update_comm_flag(uint16_t gpu_id) return 0; error: + + rte_gpu_comm_destroy_flag(&devflag); printf("\n=======> TEST: FAILED\n"); return -1; } @@ -254,7 +265,7 @@ create_update_comm_list(uint16_t gpu_id) { int ret = 0; int i = 0; - struct rte_gpu_comm_list *comm_list; + struct rte_gpu_comm_list *comm_list = NULL; uint32_t num_comm_items = 1024; struct rte_mbuf *mbufs[10]; @@ -327,6 +338,10 @@ create_update_comm_list(uint16_t gpu_id) return 0; error: + + rte_gpu_comm_destroy_list(comm_list, num_comm_items); + for (i = 0; i < 10; i++) + rte_free(mbufs[i]); printf("\n=======> TEST: FAILED\n"); return -1; } -- 2.17.1