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 F2FE0A0C41; Thu, 18 Nov 2021 12:17:43 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 653B740687; Thu, 18 Nov 2021 12:17:43 +0100 (CET) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2077.outbound.protection.outlook.com [40.107.96.77]) by mails.dpdk.org (Postfix) with ESMTP id 2F71340395 for ; Thu, 18 Nov 2021 12:17:42 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k1PbeUCo9J0y/nU9OOEbnXeXXH6ulDJdi+ZzxTZnwtKoObfklHxo2Ba3krQ+f/LI1/sLN0xUQxmZnhDwgoJ9Lx5KeabzzhiNtGHlqLKNd6hRS5v6SIcIHRfPTnXbQclX7FSqb+rwEAIpsM2NMd+ndWsuHevCfqv2/hd9wugSpc7tl60Wn2cZMcLZ9NbxK5pr0DDbbxIUuIGNSSA++okwydQzGSSrNsor6UJ2hdT/zltQlahUaNRKw5Q/6OyonTzJHvjtYuhfava6TuDE3201+HVjXzLOLWxFAraeTU0AioclSbz6dTi6l0aJ3m3jKb5q9UGZjbhMKEdNgfTWuO448Q== 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=sTzuQP/gGkoAG4hEgeBT3ebo31K+XAoazqPocR4wHb4=; b=e9MA1q6EGhqjIh/COAiKSh2r4wqA3iqlIGLBMUmp0/jAs+wjan6E/1qUQ+sAM5XHFpEN0DwA/WHAFPSTuCBGElo6A4QUcyPMkH3bcq/+MW7WwoBom77r5jxMSn0Ax9gVkfomtOkhnz4JHpz/XsQCqHySXN9G/nJiRF4SIdRPkiVvJFtRs0GnFqqlEbfIAzOtmlLUhl/FQ6MeF0yUIBksnbZYJfE29RFjinmIKMNWYxnaFx2aSt4QHce4jtewJOHdgj/pXckL4a89TTHMyclPzhBbLOxN3KTNZO/fkCyDTdpfaIkmdYXfryQdAvkdnOlZQqzJMm3SsUHNqtUswGaFzw== 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=sTzuQP/gGkoAG4hEgeBT3ebo31K+XAoazqPocR4wHb4=; b=HJNMpnCWz/TXW4n3PYlSqsHPu1vu2UOjJOL9JLXND9ygIqyeHRRpU+6ioYl0F0h4ZDiGdnxuPE4iF/oJg1/159rZjuC14cHsmD1BYx/wW0vfixzOsuNeuR6lKGGWPFN+Vofja/jaR1D9T0PixD1irtpFr34Y4cJ40j5u9O/8o3gcancxRJCANketJotL3hnkAsCeNkZgGBwFMrlspPhTR424kzU1H2bjbWVdL7V2Ka/uN02ts3XtYSePozn1OGoIBrvodTlE8qyVcEuieUMuwtZwWMZVkyTqagRsO7Z88cR1am92dQYGZx1lJeSx7l9vo1G2x3AJ24ONxL2FymNgrg== Received: from DS7PR03CA0093.namprd03.prod.outlook.com (2603:10b6:5:3b7::8) by BN6PR12MB1858.namprd12.prod.outlook.com (2603:10b6:404:fe::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19; Thu, 18 Nov 2021 11:17:40 +0000 Received: from DM6NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b7:cafe::9a) by DS7PR03CA0093.outlook.office365.com (2603:10b6:5:3b7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.21 via Frontend Transport; Thu, 18 Nov 2021 11:17:39 +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 DM6NAM11FT044.mail.protection.outlook.com (10.13.173.185) 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 11:17:39 +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 11:17:38 +0000 From: To: CC: Elena Agostini Subject: [PATCH v1] gpudev: return EINVAL if invalid input pointer for free and unregister Date: Thu, 18 Nov 2021 19:28:02 +0000 Message-ID: <20211118192802.23955-1-eagostini@nvidia.com> X-Mailer: git-send-email 2.17.1 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: bec672d1-c92c-4070-3a2d-08d9aa850843 X-MS-TrafficTypeDiagnostic: BN6PR12MB1858: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1417; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6ELdp5iGP6AeldGdiq/b0rY0trK8ZmeVJXImBRWnfllvOak5kE4KqFTJiDM8YM1O0KLAVBIfZaQv5qThKf2KsJpeipWPruM+iMFE8Xp1ZQGH2KxjVs737HrllTLIYNdTQm3S+hWKiKh0lvaEEUEPKnXICJGHEMCBiP7ow/ZbVItyFjzXJdhKFxDqz56P8wjJwcdYevn7e78BDj0IfwSBT22ZsEZbod1ZxsJ+NO7IoI3bhiRB8fHGMlnfYEUCD66PNNaQ2VOgkdvL1m4za0JyKJRjWVMgNspCGnOMCc90mC4FKjYk0N7tHQ2i8fW04X2r9qWGvwsIAY0onacrPU6BqyfIkTl4MMfJ2g2wTA2gXpNnM8c632/5Y13TH/gRsrzaDDd68e9LGh2AzpXD5FwadnoR0MSDFEkckLi9QV0Ohxqj1Ff4TBXJpZjY2lK5HgG7lvdtfjL3c2U//z5yLI67RI2Nc8dgLURoeRcjhtsADqzF4UAFyItAP8Uc300lO3PxwQVJ6GYIrRXkHVNDSknxFurtLd5gMoAjD0ge90iRMXZHHH33gW8m8EO0xblsa42PZPw3CcD5Z+/I/WskzW6c/+zcyRrqLLMRZv4sHiVis+B5YV8c4aRwEk/UQVbaRoZ12GPtdAC/MmBuLQLqTDpPXgynhTx+MUwnXiP2qFCLoTrsZLvZj1s0fgxY7EZzqgwWhSQLa7J15k8LgI1587FWJTV0PmsjWXkrfYASMHiEwRE= 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)(426003)(36860700001)(356005)(4326008)(2616005)(2906002)(107886003)(70586007)(6666004)(36906005)(2876002)(316002)(70206006)(47076005)(26005)(55016002)(86362001)(508600001)(7696005)(82310400003)(5660300002)(8936002)(1076003)(186003)(16526019)(336012)(8676002)(6286002)(7636003)(36756003)(6916009)(4533004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2021 11:17:39.4592 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bec672d1-c92c-4070-3a2d-08d9aa850843 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: DM6NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1858 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 --- lib/gpudev/gpudev.c | 10 ++++++++++ lib/gpudev/rte_gpudev.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/lib/gpudev/gpudev.c b/lib/gpudev/gpudev.c index 2b174d8bd5..97575ed979 100644 --- a/lib/gpudev/gpudev.c +++ b/lib/gpudev/gpudev.c @@ -576,6 +576,11 @@ rte_gpu_mem_free(int16_t dev_id, void *ptr) return -rte_errno; } + if (ptr == NULL) { + rte_errno = EINVAL; + return -rte_errno; + } + if (dev->ops.mem_free == NULL) { rte_errno = ENOTSUP; return -rte_errno; @@ -619,6 +624,11 @@ rte_gpu_mem_unregister(int16_t dev_id, void *ptr) return -rte_errno; } + if (ptr == NULL) { + rte_errno = EINVAL; + return -rte_errno; + } + if (dev->ops.mem_unregister == NULL) { rte_errno = ENOTSUP; return -rte_errno; diff --git a/lib/gpudev/rte_gpudev.h b/lib/gpudev/rte_gpudev.h index fa3f3aad4f..02014328f6 100644 --- a/lib/gpudev/rte_gpudev.h +++ b/lib/gpudev/rte_gpudev.h @@ -394,6 +394,7 @@ __rte_alloc_size(2); * 0 on success, -rte_errno otherwise: * - ENODEV if invalid dev_id * - ENOTSUP if operation not supported by the driver + * - EINVAL if input ptr is invalid * - EPERM if driver error */ __rte_experimental @@ -442,6 +443,7 @@ int rte_gpu_mem_register(int16_t dev_id, size_t size, void *ptr); * 0 on success, -rte_errno otherwise: * - ENODEV if invalid dev_id * - ENOTSUP if operation not supported by the driver + * - EINVAL if input ptr is invalid * - EPERM if driver error */ __rte_experimental -- 2.17.1