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 199A6A0C41; Wed, 17 Nov 2021 13:34:36 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0061341104; Wed, 17 Nov 2021 13:34:35 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2053.outbound.protection.outlook.com [40.107.223.53]) by mails.dpdk.org (Postfix) with ESMTP id 510B9407FF for ; Wed, 17 Nov 2021 13:34:35 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FUsyOwobnH1V+i4bi2VMNUtCCFDx1ObtRdy0Ade/xe6RNfVqGYXflK2CluHv9BKglpKqMTrUbxxohGdKsfsR7CC5FBdSbMBYOewxAm8LyWzZi96d7vETUPTb8TYEla93nRHfrRqkPtQjpAYB72OmZZEkSTCJET1CyDOCOvsFSQ1k5K1lwn6m5/gB4zgCR5edGqjbTZbnAC8LNMDwOGLtAfUQYnNfySJmy3GJx2gm2iCZIrNy+Wda1H+KtqXTpZig7R1aDs32JByv4oJwExtT4JW2NQZ7JUrLLOmPx4gmY+FZ5SnBrm2eOIDv2R8jx/u+selC9BbWhtXbMuWHOa8omg== 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=GdF36s9BTU7h9lqSx/HdyCBZdJlNR2jPzLvVy1RLFnM=; b=Li+lDRd3BsBEYBUWHF0VL5bmQR8S0dYw/CSwhbIKbaJSUotrCicHQbcEVqIDJYobBRCS2rysOgKC8sYsdZLI17s9BDTPZ30Eb4wrXdhv5ZCTVqcDFY7rsbrByTnNoC8H7wt96HAmkt0CWGeEwNS23e68Fiwo+ynbr5Do32GqK139RfzLZdlL4UM3MubV+Kb0QodAXpve0+3Zrit7Ne4eYcJX6GGxAiVngihHe3R+yISSR3U/wRwxAjF+FeuIOHfks1bdF+Q900fuOs4RaSp4NpTlSiFNF+owLboVK8DJlcKteO+x2+ztOrRWPLaed7VK0V52BpdFQatvKMsIGdr7fg== 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=GdF36s9BTU7h9lqSx/HdyCBZdJlNR2jPzLvVy1RLFnM=; b=j0VB5KIuA+pyz7MZgBv4bHmiE9GXbsk8Pl5SDngr7CLcm5ama/Ruyz/+27cYPFUGPPLMJKrn4Jizg3AAxaNz74gOX1+TN+MJmay/D0Y2028hVdBbCPljkFX175Qd6K6WyjWJYwPZvt+0nqO+g4+AEgOiNwuIxCxBwm0AOIs59fx/IemaouxODvcU98Js7M+wRDKnAwZp7pH5rz1v4dcqCTh3PZNvuIt8fHN5BkEwFcDv+KPNj/tPW1+HtUJUGDfekepMLcEAbv4XqsTnXWYLLFhC31oyMTMtBx8uAYEebJk1F7BMF+yeQMxUMnsQTqJ68WkMNj7rY5UqrFIQSLKKsA== Received: from CO2PR06CA0059.namprd06.prod.outlook.com (2603:10b6:104:3::17) by CY4PR12MB1861.namprd12.prod.outlook.com (2603:10b6:903:11e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Wed, 17 Nov 2021 12:34:33 +0000 Received: from CO1NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:104:3:cafe::e8) by CO2PR06CA0059.outlook.office365.com (2603:10b6:104:3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.18 via Frontend Transport; Wed, 17 Nov 2021 12:34:33 +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 CO1NAM11FT048.mail.protection.outlook.com (10.13.175.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4690.15 via Frontend Transport; Wed, 17 Nov 2021 12:34:32 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 17 Nov 2021 12:34:31 +0000 From: To: CC: Elena Agostini Subject: [PATCH v1] app/test-gpudev: remove memory leaks in case of errors Date: Wed, 17 Nov 2021 20:44:53 +0000 Message-ID: <20211117204453.27337-1-eagostini@nvidia.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: daba7f77-34fc-4d64-85d0-08d9a9c69b6b X-MS-TrafficTypeDiagnostic: CY4PR12MB1861: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:82; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NL3kcFHGNnpFwg/StxjlZYAgY36AbnLcBhfNb10VBkGi6zbt2wYdkmY1HRNetPogVTdZ4jRUVl8/5tLUClTGNraO4XvWdRUKiOrtDf3+PNZZNhrWwGp4jz4xil221U9meTjlrG5HLeaFNhhZT3RgYNdSI0mY7ldd3OW3zuED1hkO7YM3C4maY99yhD9+rjX942QT8t8q34pn+pF8YqoEhfdGZPpdoY/6hYh1X4KAZIiA3TJtYyYKt+wf47W1mIaH7i/FFrMy4pDWYTeK2rmwNyF0HYPFMjeTXFcMN5BzNO4FrdArk+1+R7QSbnILy8/X3GM5IiosD5kFnKsQRapkcHPCLCgtNm2WMt2tnfahiVFxO/74NTJ3dg02Bcl2YkR3bSx/yTFPCxMvRZiQiyKkHvqa081bUJsuUU8uEahIr/cAUNVT2hGF1IAlte805YC6BDjCLoVGhaU88DfgITD8x/VM1Oi0cKBtnBoccjtjRtj+S/lI1VwIg8C6C34qesQym+Ni9HKkp3dUm0+PL293cCuSfyEhJCjT7vvd7hP4TO4rNW9VZXILJFaPdF6KsjUQfpaouNCS/qZsVb+DvF/qrljLFZz7kEcqvs08IFDlVElLUSEu5EN/5kWNZ/NblQ0YkJYy2fl2mSIR11+mnA+iTTs2iqchsg5fh1ayPFLzmP3gQzLMMxlqjDZaWtX7keuRVIEZYCAqn5y51fkt4Vs5+w== 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)(36840700001)(46966006)(356005)(26005)(6916009)(2906002)(83380400001)(6666004)(4326008)(7636003)(47076005)(86362001)(2876002)(1076003)(8936002)(8676002)(508600001)(82310400003)(2616005)(5660300002)(70586007)(426003)(36906005)(7696005)(186003)(107886003)(55016002)(70206006)(336012)(16526019)(6286002)(316002)(36860700001)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 12:34:32.4600 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: daba7f77-34fc-4d64-85d0-08d9a9c69b6b 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: CO1NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1861 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 Signed-off-by: Elena Agostini --- app/test-gpudev/main.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/app/test-gpudev/main.c b/app/test-gpudev/main.c index c647e30de4..fe5c1e5b15 100644 --- a/app/test-gpudev/main.c +++ b/app/test-gpudev/main.c @@ -70,7 +70,7 @@ alloc_gpu_memory(uint16_t gpu_id) size_t buf_bytes = 1024; int ret; - printf("\n=======> TEST: Allocate GPU memory\n\n"); + printf("\nTEST: Allocate GPU memory\n\n"); /* Alloc memory on GPU 0 */ ptr_1 = rte_gpu_mem_alloc(gpu_id, buf_bytes); @@ -113,11 +113,18 @@ alloc_gpu_memory(uint16_t gpu_id) } printf("GPU memory 0x%p freed\n", ptr_1); - printf("\n=======> TEST: PASSED\n"); + printf("\nTEST: PASSED\n"); return 0; error: - printf("\n=======> TEST: FAILED\n"); + + if (ptr_1 != NULL) + rte_gpu_mem_free(gpu_id, ptr_1); + + if (ptr_2 != NULL) + rte_gpu_mem_free(gpu_id, ptr_2); + + printf("\nTEST: FAILED\n"); return -1; } @@ -128,7 +135,7 @@ register_cpu_memory(uint16_t gpu_id) size_t buf_bytes = 1024; int ret; - printf("\n=======> TEST: Register CPU memory\n\n"); + printf("\nTEST: Register CPU memory\n\n"); /* Alloc memory on CPU visible from GPU 0 */ ptr = rte_zmalloc(NULL, buf_bytes, 0); @@ -161,11 +168,15 @@ register_cpu_memory(uint16_t gpu_id) } printf("CPU memory 0x%p unregistered\n", ptr); - printf("\n=======> TEST: PASSED\n"); + printf("\nTEST: PASSED\n"); return 0; error: - printf("\n=======> TEST: FAILED\n"); + + if (ptr != NULL) + rte_gpu_mem_unregister(gpu_id, ptr); + + printf("\nTEST: FAILED\n"); return -1; } @@ -177,7 +188,7 @@ create_update_comm_flag(uint16_t gpu_id) uint32_t set_val; uint32_t get_val; - printf("\n=======> TEST: Communication flag\n\n"); + printf("\nTEST: Communication flag\n\n"); ret = rte_gpu_comm_create_flag(gpu_id, &devflag, RTE_GPU_COMM_FLAG_CPU); if (ret < 0) { @@ -223,11 +234,13 @@ create_update_comm_flag(uint16_t gpu_id) goto error; } - printf("\n=======> TEST: PASSED\n"); + printf("\nTEST: PASSED\n"); return 0; error: - printf("\n=======> TEST: FAILED\n"); + + rte_gpu_comm_destroy_flag(&devflag); + printf("\nTEST: FAILED\n"); return -1; } @@ -254,11 +267,11 @@ 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]; - printf("\n=======> TEST: Communication list\n\n"); + printf("\nTEST: Communication list\n\n"); comm_list = rte_gpu_comm_create_list(gpu_id, num_comm_items); if (comm_list == NULL) { @@ -323,11 +336,13 @@ create_update_comm_list(uint16_t gpu_id) for (i = 0; i < 10; i++) rte_free(mbufs[i]); - printf("\n=======> TEST: PASSED\n"); + printf("\nTEST: PASSED\n"); return 0; error: - printf("\n=======> TEST: FAILED\n"); + + rte_gpu_comm_destroy_list(comm_list, num_comm_items); + printf("\nTEST: FAILED\n"); return -1; } -- 2.17.1