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 62833A0C43; Mon, 22 Nov 2021 11:14:03 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DEC95410E4; Mon, 22 Nov 2021 11:14:02 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2073.outbound.protection.outlook.com [40.107.237.73]) by mails.dpdk.org (Postfix) with ESMTP id F395C40395 for ; Mon, 22 Nov 2021 11:14:01 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hb8XEbcCQIhhMWySbV86jXf21+TDhkaEBEfV/xkmgk2lxwMz7xX4EHaHqm13tCHPZzPWu6V1lMc7FA7c/k9rgJz6wQ4yX/wxKyywC8SJsgSpo9fsaklMSzDf6Kri76ohTtdiTe886O6ox1d1EBJzAyG4V6OoGDg1qEGwsCdNbVeq0C1sokYmkUso4o4maBXD1+WOcgQAY5o3dRdR3RZygEdpM742hn1weQlyxxWY4mWivuWU2nYukW6oqqGsLdpTXmDCSWnHGnv8kbzWqnQT5r3xNqK9xunO79EUEtShTtHqtpHpqv+CmSFhGiOrKmR9veEhGJTVidSmiVPo/xUC4w== 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=9hEM3OznlkGhH5ZkXrnO9Pv6Jzz+YjXmjzIR9TCTUoY=; b=McfZTA2NpWmlp0uPxvLzDWHLaod7x/j1x+C1C9jAqSXMlPMR7cCu9YVrtv8j3otY5PHGxqtws/fBJIoA5XNlPe1qpBEZMeDTEcJ22N44VyiJYZwBYfXiifvrSF8oP1Oae7iYLOK8Rv8kQjwQNNhMduyHITBqoY8Uo6yoMfpwlZu2PH48KsCr2zPh3ML7pQwUqI2SeBi+/BBJsXI1XZbAkaDAUFVjJHGVXDKaCDPyvh7ttIxgPPt36n+GubruLVNmUObOMQfgNz6b2nzvUZa/odjiQiVWIDED8pEOC9znAfAWTYGi+NuG3Si6SujQRFkOnQIoe/fg1jiwUkSqyTnUSw== 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=9hEM3OznlkGhH5ZkXrnO9Pv6Jzz+YjXmjzIR9TCTUoY=; b=l2PmM8gVVzJFBWIyybXRMazwQ0YYR9k9BD+1kvIWxf7HYhs5p+WgzyCWaB5ps7mqTYhhZJIrTW5AqGvhkfo+9d/EtDqiSqZKAD6iyE1ub4sUkeQ+/VAuBbXmHv0j4MZwZana7de63wkN//7mehkcIIY+CvRTyMpBYM18RiQ5++d+J95J4EIYG1D+1jF4I/NAs6lMUweWGMQJWcee5mPUiX9vgQ+0yVsYKRUsgeT+R1nhBU6rYMspCo8Xg79cabZbL66+fCTxoAwlAeBMq0KEcxWyEvoSN6o1px+Z3xqA4Vq6QDB/HbXXsRwrqXIU9v6Vi/+ygLNxRixYckw3NnlgXw== Received: from BN6PR1401CA0018.namprd14.prod.outlook.com (2603:10b6:405:4b::28) by MWHPR1201MB0144.namprd12.prod.outlook.com (2603:10b6:301:5a::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 10:13:59 +0000 Received: from BN8NAM11FT061.eop-nam11.prod.protection.outlook.com (2603:10b6:405:4b:cafe::f0) by BN6PR1401CA0018.outlook.office365.com (2603:10b6:405:4b::28) 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 10:13:59 +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 BN8NAM11FT061.mail.protection.outlook.com (10.13.177.144) 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 10:13:58 +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 10:13:58 +0000 From: To: CC: Elena Agostini Subject: [PATCH v3] gpudev: manage NULL pointer Date: Mon, 22 Nov 2021 18:24:23 +0000 Message-ID: <20211122182423.5581-1-eagostini@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211118203354.25355-1-eagostini@nvidia.com> References: <20211118203354.25355-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: 3048a973-4789-4630-ebeb-08d9ada0ccc9 X-MS-TrafficTypeDiagnostic: MWHPR1201MB0144: 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: tzvcfCLXWmrL1vPPmAf/lnwIytPtohckDMJqKEy96lrlpQVKLPVROMx/qXcLsoYz9utHWOUW0jHXuEE+o1o8It7c+cyKPeUrJy30uOMDMeqq1QdHuztygzdiTZ5BzpZHRuGMOnmllaAcrlPFQMUzVkxHUxdyToCWxhkU3dLJemeUdY0+Ey7IJpJhwaCoSaJUgitfLXmaCKQ3Fipk8qCoC+zI6KpsBnPCubFG8Dqht6vZ6oPPsw9J5OUaGHvi6HuM7JwnnKh87fpDAKItoD1z4Ro+0SuLH5yY+3nBlVBqjINt7fVLnsb8Xzfhfk18msSuRVVvZAOI7LeY9J+QO23wO3k+ENvOxvv/CLATy3FHW5pQPhjUnZKIBFxGEP35vtjuHOKZeHomLvyc2wlS3TH49kIss2CbJbje7wmsqZ51vU47sVYHqSnpBqEq1GrkgCwWF33/5p9MHoFV/DSo+5lwIraujBMwUl2AFnW9w9njqYmLU1uReAg3UzjWkgIOpIoIuaf9q9D3M6qGuWMQljFkmXTeVF8kbMk3JwjIlaH39KMY/Z/sHZpi6XCOAl3a/B8anTUGpDRmZhqoGBplS/eZ59vqQqaP8FMm7ribL+hT/4aaZfD/4Ehq1wwd9sotdEMwEX8qhY3vjsmpknDEPbT8wU6IU3fEvXSozFnq8+4+tC0YLa1JP+XkPwbjSY4j075zamnNl+nO6A8aT+z6CkcFLQ== 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)(6286002)(6666004)(36860700001)(316002)(7696005)(2876002)(6916009)(1076003)(107886003)(8936002)(356005)(47076005)(508600001)(36756003)(2616005)(5660300002)(55016002)(8676002)(83380400001)(2906002)(16526019)(186003)(7636003)(86362001)(26005)(426003)(4326008)(70206006)(336012)(70586007)(82310400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2021 10:13:58.9804 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3048a973-4789-4630-ebeb-08d9ada0ccc9 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: BN8NAM11FT061.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0144 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 Fixes: 818a067baf90 ("gpudev: manage NULL pointer") Signed-off-by: Elena Agostini --- drivers/gpu/cuda/cuda.c | 6 ------ lib/gpudev/gpudev.c | 6 ++++++ 2 files changed, 6 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..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