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 DED43A0C41; Thu, 18 Nov 2021 13:23:25 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7339E40687; Thu, 18 Nov 2021 13:23:25 +0100 (CET) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2059.outbound.protection.outlook.com [40.107.212.59]) by mails.dpdk.org (Postfix) with ESMTP id BF8F440395 for ; Thu, 18 Nov 2021 13:23:24 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=azHNb2XQWgOZAs1YbOankPvXegpgl9ItrGnKP64d7vLCZQ+28uHIy21eHXcElR2nECnojA/nF8OF22WCJOTNYTPI8z3aGTOQQP9yCr6PkasYAXj3UzVLjfcRQB7nDUzyUGnYYO38RM8VN0wIJAaXALMqtrVYnasNK6TzrAhdzkMGqEPq81DIIsPQ1SSBl1IRVesLh3yUFCSXdcRHbJ0IfUCG4nF6T7S5p7XnkEGv11QpfIz+MoNwkLdBNDs6l62W9oDfLOozeBjgJ2LWnl8f0oA9D4JwrvdZDJod9mNa92RB4dgtNPAz+dsCz0drxTefK+o0Txu1bR2MvlPFMgQy1w== 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=CqPQtGVi/csJrncDjyMpwcOKPFlblP3cvwPU7IxybKE=; b=J/EhEbx3kMoBh9B//B7WbhnB2m2JGL/3l0VpfhMQVkCxMYLJiIgO5qj1OVfu+6HR/LTsTa/e9Psx3d/GNZIWIXVAogyZqOjVw01UwXKcP5XTUbV3pWoL0pQnA2bkKDpSbiSKRQooq4aiX4tJu0Zvi0ufouqsC1ByPuthxy3rC6XZ2/pRAGksl38zpwTtY6Gj+2ZwYWDqZUconSsKiGD3GXa60ShhO4M2eaA4dRLrob2T7EpUFTqFmKPWcZ83OSjYHMJOyqmB4GhdoR/foZefYI7q1Uw3esTHHqMb0pE/iGgibR88uBnS040nCbEFmphvXZ3xwfDIeiVKpx1Xs8diGg== 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=CqPQtGVi/csJrncDjyMpwcOKPFlblP3cvwPU7IxybKE=; b=db2rSlWdCq/gRMffZ6AInm/G9lydgRa0JBgGjXtZ3jQiFEiDZRJNLJJa4c6T0oETCONiKHg2SUaAA1Gvn4MxFYqSsi31PQv1kK4y8fJ3nqpvPVWw3e3MUKkNRPiAp7CPP1Sw7YxTLKPAKP5Uwv+4dk1pHsjSQXgn19WBmQ4RRkoKnAEZl3t87ivsAdT5xAARg44EFRkdSnUwm4i+Hs0OGRwA6mDJNBV3BXyvtAepk8LbqeFr2LbwTLPS7HW/LZcxFGStCoJMY7Jwxv5u7XFUG60q8/1gYpuxryAMNa0UVMS0xPQUAFtLixvOUEBdTDrZgql6BVs1Wg8aAyLgwiUQow== Received: from BN9PR03CA0737.namprd03.prod.outlook.com (2603:10b6:408:110::22) by PH0PR12MB5404.namprd12.prod.outlook.com (2603:10b6:510:d7::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Thu, 18 Nov 2021 12:23:22 +0000 Received: from BN8NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:408:110:cafe::8e) by BN9PR03CA0737.outlook.office365.com (2603:10b6:408:110::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.20 via Frontend Transport; Thu, 18 Nov 2021 12:23:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; 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 BN8NAM11FT048.mail.protection.outlook.com (10.13.177.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4713.20 via Frontend Transport; Thu, 18 Nov 2021 12:23:21 +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, 18 Nov 2021 12:23:21 +0000 From: To: CC: Elena Agostini Subject: [PATCH v2] gpudev: free and unregister return gracefully if input pointer is NULL Date: Thu, 18 Nov 2021 20:33:54 +0000 Message-ID: <20211118203354.25355-1-eagostini@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211118192802.23955-1-eagostini@nvidia.com> References: <20211118192802.23955-1-eagostini@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.187.6] 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: 2f5a63c4-23c7-4475-47f7-08d9aa8e35e8 X-MS-TrafficTypeDiagnostic: PH0PR12MB5404: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1775; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7M+Yw/s8VSrJdauC71ZsbFpyLlxGEqjEL+vbsqS15BPHiSfiq0Q5Tn4YNyy9TabQ5ZG5XkdEznxHfEDpnOpQfRWW+HHDmP7RpBunIcfYdIw7D/AqrGyIEOnnKELonCIMhGWh40tJanjRpUwyrCLwXz/koTSSuWGxDriVKQCVW4Wnj0LK5BDy9cmm7MWKLqg7hOJPoZ43QUeUftgThYNQ9xdXRi5YyDIlQqOt5/Lq8XwjAIgdSi/817ARsuGPmoau88nTmRp5sU6RePpZpzOikitxiy5/Yuw/cYBRRQLBet8+v1LGiet3Iw0UhOkeZcVSAvxHBCyu0vrsnANVSplhsWBkG6zgFtyabNlWrFC2tFpULj+wIzuDgCuqntYWkLO4S8cB1ouE2uib4zxa0jmlgeWbEISRrXbGX+b6+25BvMLYxPrYIi7dpJNHCDhl7ozwmzV81NCqO5fH/sSWW3I6zdngW67MC2vZUuXduL6+631rDneGGyl4QtMZ+ZAIxaXyFPvRgubpGszQvaCythghAgHVldgwdwhiXgqrC4la0RNI0jVj4qup6aDEm7JJXGIhlz2cl5QqXrZcTrr5l3HSQ5MEL3egL/ByjPjQdU1WoYtsEoniwBl4Cemt3weD7LtBYpV/chnuG4tV+igth+hfz+V+M2c5OcM0DX/U0ctCLb1jCRdCNgdrT82ycxjMP7Xt98a47XQNhfpwOLJbM9cXpg== 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)(8936002)(16526019)(426003)(2876002)(36756003)(336012)(186003)(5660300002)(36860700001)(8676002)(2906002)(7696005)(47076005)(2616005)(356005)(508600001)(1076003)(6666004)(7636003)(6916009)(107886003)(316002)(4326008)(6286002)(55016002)(86362001)(70586007)(82310400003)(26005)(70206006)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2021 12:23:21.4240 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f5a63c4-23c7-4475-47f7-08d9aa8e35e8 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: BN8NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5404 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 --- drivers/gpu/cuda/cuda.c | 4 ++-- lib/gpudev/gpudev.c | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/cuda/cuda.c b/drivers/gpu/cuda/cuda.c index 24ae630d04..f68e2b20b9 100644 --- a/drivers/gpu/cuda/cuda.c +++ b/drivers/gpu/cuda/cuda.c @@ -765,7 +765,7 @@ cuda_mem_free(struct rte_gpu *dev, void *ptr) return -ENODEV; if (ptr == NULL) - return -EINVAL; + return 0; hk = get_hash_from_ptr((void *)ptr); @@ -804,7 +804,7 @@ cuda_mem_unregister(struct rte_gpu *dev, void *ptr) return -ENODEV; if (ptr == NULL) - return -EINVAL; + return 0; hk = get_hash_from_ptr((void *)ptr); diff --git a/lib/gpudev/gpudev.c b/lib/gpudev/gpudev.c index 2b174d8bd5..b41c43016a 100644 --- a/lib/gpudev/gpudev.c +++ b/lib/gpudev/gpudev.c @@ -569,6 +569,9 @@ rte_gpu_mem_free(int16_t dev_id, void *ptr) { struct rte_gpu *dev; + if (ptr == NULL) + return 0; + dev = gpu_get_by_id(dev_id); if (dev == NULL) { GPU_LOG(ERR, "free mem for invalid device ID %d", dev_id); @@ -612,6 +615,9 @@ rte_gpu_mem_unregister(int16_t dev_id, void *ptr) { struct rte_gpu *dev; + if (ptr == NULL) + return 0; + dev = gpu_get_by_id(dev_id); if (dev == NULL) { GPU_LOG(ERR, "unregister mem for invalid device ID %d", dev_id); -- 2.17.1