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 5C00CA0C4B; Mon, 22 Nov 2021 16:42:06 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF7E14014E; Mon, 22 Nov 2021 16:42:05 +0100 (CET) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2049.outbound.protection.outlook.com [40.107.100.49]) by mails.dpdk.org (Postfix) with ESMTP id 28A794003C for ; Mon, 22 Nov 2021 16:42:05 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YE1o7N0PSIUmIQtXBD8xPTaQaTeX6A5e3fxdcL7Z0C61HpgmZIyls68K6/JDLBE63Td5RZX7yvNQ9w9M+szHiRipK76HZgEIIuE0CjzgrN8wCI6QOviAMe5bKGFTWJKvEZsPu/WsPBOY3+9RcMOZk+S+p44CQKpE43o6G02/AAO+GntMTh1xpTMMSIN0zQlsdL0JRD+OZKO2SuoWUnWq6NQcK0Iz2LpuLFI70v7tZ3V+7eM7/p5wwYoevTbUAANxF5WyGDdVhfCGBWJoO74CnjP+DSMdDQ/lFdGz3W3OlUxgA8UHU5g9JnYTRTq52VmEnJzwmuPcIQI6nUFpZOHEjQ== 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=t8Z4eRgcS76xuBcSLZM+uKSVH01ODnTgz47ekJRwETY=; b=NVuayBI/rEjfGNjWzmAG25z4Xjgv8NZenYFna4XF5+PHj3Rt6ATAb1zxWBOD1j2RVr5XyoSfSRcnjSxNKppsNQ6ZS2/9qrsuPetCcYChMyVTwKt1XbDRJvU+XZRn9AriHQAKq2krGDDges0rt3L3w0JMVWqCNjm5+xKYeUE4IKWnvH0Hxow6xntcqNlDaf8iqtAJG3XApo6emxtOlWKelZOTX8erJnkdNssdveu90+VqhLyD3pvRrPHcUvaHKyeCbNyEvBX4sbrkZ91g2abg0MGvNW1iNDkDqc7V9z5VZMOHBxetQUSgbHgMPLs2s6yE/t+wHdebTtomnyl5H58C3g== 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=t8Z4eRgcS76xuBcSLZM+uKSVH01ODnTgz47ekJRwETY=; b=ir+PeKQuPH2ImokauTFF5Za8usrMukG8l67+frn1mSvO2xVap2mvJLAA+ij8z9eei62E3aBra6i4YmPuj70Hzo4VZ+xmW+led+zuK8coHhM1qLFowMSuDiWDTrC0IWHntvx1V1TMvwGVW+a0H1F8eipdQlsKXWoLNH6ng/PvyluFQ/b3oSjQkENdcKbtG3cv3WikQEJSMrDYdUV0CXffi9GUtEb3CWpbrx+N5U6MVOKTxre3hVnHGrGijCbWKkC27K8Oc7kggWH7MsT6UZJ+xCZ1iaZL8re50g7gImKrRcBy5PrKDaSyJ+RT09uVnH/K6xUDZLC+S08TgO+o6QLKaA== Received: from DS7PR03CA0306.namprd03.prod.outlook.com (2603:10b6:8:2b::14) by BN9PR12MB5113.namprd12.prod.outlook.com (2603:10b6:408:136::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.22; Mon, 22 Nov 2021 15:42:03 +0000 Received: from DM6NAM11FT012.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2b:cafe::cf) by DS7PR03CA0306.outlook.office365.com (2603:10b6:8:2b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.20 via Frontend Transport; Mon, 22 Nov 2021 15:42:03 +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 DM6NAM11FT012.mail.protection.outlook.com (10.13.173.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4713.20 via Frontend Transport; Mon, 22 Nov 2021 15:42:03 +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; Mon, 22 Nov 2021 15:42:02 +0000 From: To: CC: Elena Agostini Subject: [PATCH v4] gpudev: manage NULL pointer Date: Mon, 22 Nov 2021 23:52:29 +0000 Message-ID: <20211122235229.22019-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: 18595ea9-d7d6-46f9-5feb-08d9adcea167 X-MS-TrafficTypeDiagnostic: BN9PR12MB5113: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wEkmGKCQcoKuHGc8i1t4vUSLiHOObWuqxNdMyb9vZhxxK0ubF9B3gz6rhGoRCVvsIlwr3ZKN4r5m768pohKuSHPs1agfZhw6Z2TO3CiEzrP3ogdAAxIOybXpG5qvpr8/GB2F+4+PBN36Xad0LgnuiCErBvfcSrQCzeE1EjaxoaqhmZT+4SEU931/YtL3HVnjtRLiMQdW3GZgls4jxIFoU1uuKC2WcxovfUCYSoSjV4ie1Suqzl5w/d3qB6DMusdh30NYjjdGSp6XpYV8EtCFic0dCzsPCkUqQ83S5+UYk8cLVuXBQ12s+kMr7GnRvaZRU+holJ65S9OeXWgZAaFyR2vaHBK82NhdgdtcAmjaePTK7/nSUfxiNlrjYJDYrHdPHqnO7K5XKId4r4SleD/D5eLYxpD98RWJC+S0IJxqmA5JoiPJn+unV3wn1AIoeQmdg41ixnXaz88k8ftqAP5723NmWsRS2pOdcyTEL9KJ4GbIsR9Um/gMm7CfPo+N1wqtL4gpgT1u/dkh3ksh3zCX9khr8gl5sjWi06aWqunB96BKq2KAzzY3RaHelHKMIklbVAJPgqdZkLP+lpNNdOuA4Vdpr1URsJugSTegbAw4mblftD3sf2sOGOt0ybBvPKnexJJd5xw2HGd2WPCLKC71/yT9QbV8VfKfWEmn/xDNBl0IlJp7fbtm4jk8W0+R+GZtY/DGAuitYKDYpq20t748Og== 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)(1076003)(82310400003)(426003)(2906002)(6286002)(336012)(70206006)(47076005)(70586007)(7636003)(186003)(36756003)(8936002)(107886003)(36906005)(7696005)(4326008)(16526019)(83380400001)(356005)(508600001)(36860700001)(8676002)(6666004)(26005)(2876002)(2616005)(5660300002)(316002)(55016002)(86362001)(6916009); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2021 15:42:03.1341 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18595ea9-d7d6-46f9-5feb-08d9adcea167 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: DM6NAM11FT012.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5113 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 gpudev free and unregister functions return gracefully if input pointer is NULL because API doc was indicating NULL as a no-op accepted value. cuda driver checks are removed because redundant with the checks added in gpudev library. Fixes: e818c4e2bf50 ("gpudev: add memory API") Signed-off-by: Elena Agostini --- drivers/gpu/cuda/cuda.c | 6 ------ lib/gpudev/gpudev.c | 9 +++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/cuda/cuda.c b/drivers/gpu/cuda/cuda.c index 24ae630d04..47a3bbf256 100644 --- a/drivers/gpu/cuda/cuda.c +++ b/drivers/gpu/cuda/cuda.c @@ -764,9 +764,6 @@ cuda_mem_free(struct rte_gpu *dev, void *ptr) if (dev == NULL) return -ENODEV; - if (ptr == NULL) - return -EINVAL; - hk = get_hash_from_ptr((void *)ptr); mem_item = mem_list_find_item(hk); @@ -803,9 +800,6 @@ cuda_mem_unregister(struct rte_gpu *dev, void *ptr) if (dev == NULL) return -ENODEV; - if (ptr == NULL) - return -EINVAL; - hk = get_hash_from_ptr((void *)ptr); mem_item = mem_list_find_item(hk); diff --git a/lib/gpudev/gpudev.c b/lib/gpudev/gpudev.c index 2b174d8bd5..d6224a3828 100644 --- a/lib/gpudev/gpudev.c +++ b/lib/gpudev/gpudev.c @@ -576,6 +576,9 @@ rte_gpu_mem_free(int16_t dev_id, void *ptr) return -rte_errno; } + if (ptr == NULL) + return 0; + if (dev->ops.mem_free == NULL) { rte_errno = ENOTSUP; return -rte_errno; @@ -595,6 +598,9 @@ rte_gpu_mem_register(int16_t dev_id, size_t size, void *ptr) return -rte_errno; } + if (ptr == NULL) + return 0; + if (dev->ops.mem_register == NULL) { GPU_LOG(ERR, "mem registration not supported"); rte_errno = ENOTSUP; @@ -619,6 +625,9 @@ rte_gpu_mem_unregister(int16_t dev_id, void *ptr) return -rte_errno; } + if( ptr == NULL) + return 0; + if (dev->ops.mem_unregister == NULL) { rte_errno = ENOTSUP; return -rte_errno; -- 2.17.1