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 78BB1A0C4B; Mon, 22 Nov 2021 17:05:21 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 11B724014E; Mon, 22 Nov 2021 17:05:21 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2048.outbound.protection.outlook.com [40.107.236.48]) by mails.dpdk.org (Postfix) with ESMTP id 1E0B14003C for ; Mon, 22 Nov 2021 17:05:19 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ila9JksTAQjpN93n1giZTqTdNuklLO9tLKe1FA1tKXGXm93SMzbM6v5XQSuQemY0843BVIRMy9eN8AzeVbao1PNARKUtjZO81zFYX/qrhR9jzUpOgEkahz8ohCSjaDKozDBoZhKKPtSiJKtuJtLofJPDzlrd4+fD/Hm+qmEz0sQHmZ5CQzmpBPxgTZnCfQOIRNCVKRIP6jJoDW63tbUs0W2jmwuXbYL0INUQ7+QVmENIU5qeVampHYKriOuNlbWeOb8ViSdyONCqFUhPHU6mMrt1j++uXuhj81D/Ptgft82orX6jwLCXXYpHib7vwKmV6LrZWfsy3mkHRrYbuwEg4A== 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=M19GrhQIpf5MU7xdjcoT6XJ1hy0pI4QBE8seeN4ivSg=; b=DLSZ2ZC4RrJFuQNZIOtL5jx4Uz9rZrUJ6EymU7bE7Ay9yVnHDI/1+j4D1VHZRjERbmuJExX5JPcg2pPo9pp/IeyL48wUmoD9LOy5vTqadqdbKDS6FRMHSZrjy+kCuLk0/SMh/9WalP16hPadi1b8H08PHsnFYxYn3elSzev+Ps5YEIElGgjjVnDEe1fFvlTXXMn4drgWKwP3KPDeFw0iCkseLDWHpMM4f1enoTUW/ENaiM2YSj7aTM650+fbffI4IvdzmEStFeAZ4DyEai6DUirpyVbkVQPI6IIqaHImcV0hb4g23xD7QNi2Ws+YhOJYJ6gJjxM7JZVt10aL8wFfSA== 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=M19GrhQIpf5MU7xdjcoT6XJ1hy0pI4QBE8seeN4ivSg=; b=n0EvQ5JBoJkgeCr2pn7ZQOHSdBHUtT0bczb3Mdng/VQz+67a+bYZqifgNNRO0hm8CStYZgwlw4emDX+Zy7zTTuzHIGi48nN4W+ER8251kZdP7WpOyz8f9P62QJ43vg7HEjUYXW5AGddGN9EqPjWQA1QvqNKwlVg6L3U3q9lNdqhYwAHBSUwwk9hOdvqat+zjbgFbcRjGfRPz2+q/c9k8paHViP4EyvRXMh4xSg21EY8KROGBzeXrv1QvIuHIcYkgmeIYalq1yWfqvr8HHWn9jBjK5T98bKFmlDmXIWHC5ldwyKqwEg22nPwFYOBlghJ2IlowMYR8GRWAX5dz0DjE0g== Received: from DS7PR03CA0278.namprd03.prod.outlook.com (2603:10b6:5:3ad::13) by BYAPR12MB2887.namprd12.prod.outlook.com (2603:10b6:a03:12e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.21; Mon, 22 Nov 2021 16:05:17 +0000 Received: from DM6NAM11FT061.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3ad:cafe::6e) by DS7PR03CA0278.outlook.office365.com (2603:10b6:5:3ad::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Mon, 22 Nov 2021 16:05:17 +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 DM6NAM11FT061.mail.protection.outlook.com (10.13.173.138) 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 16:05:16 +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; Mon, 22 Nov 2021 16:05:15 +0000 From: To: CC: Elena Agostini Subject: [PATCH v6] gpudev: manage NULL pointer Date: Tue, 23 Nov 2021 00:15:42 +0000 Message-ID: <20211123001542.22687-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.5] 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: a9380eb8-ac6a-4107-7c2a-08d9add1e030 X-MS-TrafficTypeDiagnostic: BYAPR12MB2887: 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: 4RA+1nIyO4XpZeJVdQ/anuiz8rqKLDEZLuHGWJ61xAedaaRjWvmTsguxi7SDc2BmZdoNuA68Vybkv4w/JzMW+UxG637lLAQ9YbhCkLI3TMm8ZpGbBKx+k4SGOvOQPtW5x9NEATWh68uVJKmZORrV3+ynH/AJ0saaFEox3mqQUK65aXKyqirhUPuEGf645+c+3bCspsU9nJSlMZHKclrrbR+LDCqtouxYRJIPJOa5Lf/wvbZR+16bULdsbNKthbTqx4E6F6VKORLhZe8nV+GsBYn43wUEaFN6nGlLpPU2M/Hwt1gljj0BngGhxM4rD1SqnoKGNiKhZ6qkrXPkhEroD6keIvRMFc03rc8DBfaElXP7EoUkPWfl0VlrdHXWWy+RhzoJkXhlBQGeLBcl28wCdLAPTGL3fZSh/PFJBkOfEOiAiztCntD2g9mCxso5Wagyd/DH02DVKBiuLQ0jFYrkrZV+jbVpa6vRDtllNIB9bynxs+30tfgWRJc/LYXTe4Cob3Wzyp1zx/Vb37CNVHeG0/nm7VqKTng+AwVn4yCv6JOzPlQNQIHH7bnlfLWozAGaagXgq7W+LHMfLZk0nPc9iNTYshsZbw76u3zPW4SQTG9+6C0EEWCb52H6YNcl6L+wJbP9Cr1O5MQN6FUD+9CJ3fcHiDhpWGI+T7uE3sKlcs8kmrHSI9LYgKnNb+z4JGZG4E7Cy2EbNT1UZJ1mmixaeA== 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)(47076005)(8936002)(7636003)(26005)(1076003)(6286002)(36906005)(356005)(70586007)(8676002)(426003)(36860700001)(86362001)(70206006)(186003)(6916009)(508600001)(316002)(4326008)(16526019)(83380400001)(7696005)(36756003)(82310400003)(6666004)(5660300002)(55016002)(2616005)(107886003)(2906002)(2876002)(336012); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2021 16:05:16.9520 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9380eb8-ac6a-4107-7c2a-08d9add1e030 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: DM6NAM11FT061.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2887 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 | 8 +------- lib/gpudev/gpudev.c | 9 +++++++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/cuda/cuda.c b/drivers/gpu/cuda/cuda.c index 24ae630d04..f59951f11c 100644 --- a/drivers/gpu/cuda/cuda.c +++ b/drivers/gpu/cuda/cuda.c @@ -652,7 +652,7 @@ cuda_mem_register(struct rte_gpu *dev, size_t size, void *ptr) if (dev == NULL) return -ENODEV; - if (size == 0 || ptr == NULL) + if (size == 0) return -EINVAL; /* Store current ctx */ @@ -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..7aeaf931c3 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