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 5E6C3A0C4B; Mon, 22 Nov 2021 16:45:27 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0F3E44014E; Mon, 22 Nov 2021 16:45:27 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2054.outbound.protection.outlook.com [40.107.223.54]) by mails.dpdk.org (Postfix) with ESMTP id 2F9314003C for ; Mon, 22 Nov 2021 16:45:26 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FSJm689wCPpi5nOoWg4FqXWRtFcSbRVvnHEMpsoXwhqyFZ5buTiaOIsT30fVjiKDluGgyMM1WZMRj8U6vNz912/J6QndptiDbjjzRSu+ArXSTS2bJyWNrrfMeNdS7GDneTolFwxHx0Y0RbOmP5n9bqajCa4EFSOp+O/pR+T7EA3z4HBBC9JHoZaLZOvksBtE6nMsBX3/RmKUnniWYfzsbkVsGEGE7Ptr1LOcz5FCpOhkSc4ubqNyvaH/XUL3K48CHS0C5gUC4Zz+cr1YWOGl/NxqmwvT9QmRMeY/k3MM1QKTg/Aix6pHObq5ptT89X8Ctdux32oep5KxcfdT6fbpkw== 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=hk6QqnpH3W8KmcpkOAQc7ZSYCNQkJ5LTyrHvs/jSSeE=; b=M6RTHG1Q+vSpl02EIZsDtsaq79q0bcCokpVAr80LBMgFr8/LruQV7qFzF6+h+RA7BNEvu7LKbuyYSd64uM2GYfBgbBw4y1YcfQyDC+B6mo/UW9o/2EWdozgDT7Mwmxt80xZF4JQquM72U3jm1ENj59OGJCvd5ienesgdMo3oTlZid0OjmPlkxPJCJDJUpRxj/NWwjx9ZcXryIV9xPiS8tXwjeB/N/pdfcbisvJg6HOOsU14U9twDmU9IoJpCNF/C0y7R1KafJAfHlZpN1vMaEYsAhUCwaWNcNTgED64MJiZhuEJGyPEUXzlj4bCrjhHdetbvk2I5WGorGF0R3BBEiw== 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=hk6QqnpH3W8KmcpkOAQc7ZSYCNQkJ5LTyrHvs/jSSeE=; b=VhqS90vLwCbCLoOMmygy71LpoGsamcic+8tiFTG9e1MnrPMM1PdZWYtnmzLxhXtChtmlkXHcNI9b+e/pHO+2Lfrw4RKlJD6syw4CWJ71sbh1H8dnSvb/eYuViXPf0ogbSjvtpXVzRlFxDqqTzhbEgVH4r4S/pnEmDGj2GHN2d10wX2ZYXwtCz+IFl1pxeXPLO8bO/rdkCkTvfZXtFzrkUl9BuxVTzVQcSpIO+Yf4kRFSw/gnHvLQfMlvPO751+DPTqSNPMWqPCoZHDpQ8BqvUTNFYBgDNaw4Y8pFpaPmjNWAYl4sX86SLDk8xKJhgZ9ObSz5igOoVR3XAbbXcKjMhQ== Received: from DM5PR19CA0063.namprd19.prod.outlook.com (2603:10b6:3:116::25) by DM5PR1201MB2475.namprd12.prod.outlook.com (2603:10b6:3:e6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19; Mon, 22 Nov 2021 15:45:24 +0000 Received: from DM6NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:3:116::4) by DM5PR19CA0063.outlook.office365.com (2603:10b6:3:116::25) 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 15:45:24 +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 DM6NAM11FT035.mail.protection.outlook.com (10.13.172.100) 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:45:24 +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 15:45:21 +0000 From: To: CC: Elena Agostini Subject: [PATCH v5] gpudev: manage NULL pointer Date: Mon, 22 Nov 2021 23:55:48 +0000 Message-ID: <20211122235548.22344-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: 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: 283937ce-10a9-4563-ece8-08d9adcf194b X-MS-TrafficTypeDiagnostic: DM5PR1201MB2475: 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: StEChs4zvz9lHKkRaQ0gIXOLE4Sv1RWQ4hhC2evX802kS8MMPtotwwr6KrY5Gae2mX4NyzQrbtBRHXHQzCDkzo9mIAuFzK8CAhnxrAyriPpx9ZmPORRDxZ3+PMBUVAEGjs7ThO8uOxgfTWR7bagPA4vKQYMY+Um6kgqkmMn6fsXa5iupg27yte0uE1sWRd2LQhQq2D2qazQuc2CuUhuVlOk56oi8Ctw6t5xGIHn+ECQ4bAdJvuDN9rSPzt0xkhdmZZ8AN8swNZ1jWKvGfmlc7rwph1Qvb752BKKAlc/VCKgz2ufggI03Ah9CqkjOjo48idJ8JuYvWwA7BfFKkb+pEmrahNyuUDL2GWP1j0yv/tMRr91MyG6t7RzSE3IDrffJV39feDUvNTe3XKJhLnovxuEIEwrmwQclVZiQRWhX3Lw46yjXZEI1WbrJt3dqZ3P/BLVgK1C+2vCFuzgW6YTuabYpnWaD4C4jiK+qbaohRMH+3TK+IMaV/hXgT/vSvij8+MIKg0P2nK8/OgGmP4xEVTfgllugDQ1KTCbyE32RGdCDoIC8W56R3aIJ0irAwEqWNpg0Diyb0jOqKQyf8C62tXP8S/VjWeKDsaiYpXzB5aGxVWqg+P9CMnR4diR0mpy91WhhODLzO4Nxx9T65jQ0knGHEgSP9vB5pBERY4v6hoFMn+kEGQnucQch3F9NOYMMLgSIKj6wd7HAaiuAwzMrow== 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)(8676002)(55016002)(83380400001)(508600001)(7636003)(5660300002)(70586007)(4326008)(70206006)(36756003)(2616005)(336012)(82310400003)(426003)(186003)(2906002)(26005)(16526019)(86362001)(107886003)(2876002)(6916009)(1076003)(36860700001)(6666004)(6286002)(47076005)(36906005)(8936002)(356005)(7696005)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2021 15:45:24.2778 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 283937ce-10a9-4563-ece8-08d9adcf194b 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: DM6NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB2475 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..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