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 C8F0FA0547; Mon, 22 Nov 2021 12:23:09 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8D3B1410E4; Mon, 22 Nov 2021 12:23:09 +0100 (CET) Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by mails.dpdk.org (Postfix) with ESMTP id 7581740395 for ; Mon, 22 Nov 2021 12:23:08 +0100 (CET) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id DDF835C0085; Mon, 22 Nov 2021 06:23:07 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Mon, 22 Nov 2021 06:23:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=fm2; bh= qat/Tano4h0oJJBNokxAgEXlFUdPoI3ze0hXnGifqQM=; b=qRkAzmoRoF9vErS7 UzOI6D89pVSllmIzmOQL3fMmMQJ03YVigI7oFfirybf/3Ln/if8VhOFHfYy/e6rU jXbbIA/USjl8GqNYEPKZdlfuNFxA+SIcb5zV7xnfTH+JkoCkaXqav06CPtW6tqSM rH8gf6bSqlmVuTddpc9vxwT58EpaTJSh3IXl4TbCu6konsehUwcFr9D5TgMJwV5x BRdU3Hft3yk3wL6PKMUhGV84LtFnfiVuqrtqt4QAt8GNsjFCl/dFoqqvbrjOE07M uEgMhdn2aOHRQN9WFzwZmj89YzG6wnF+R8Bshij3yaqlLwUBXXfGZLT8B+5cRSZJ PzbZTA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=qat/Tano4h0oJJBNokxAgEXlFUdPoI3ze0hXnGifq QM=; b=Ox4hptYwCJiyPc+yDyW0PCmj/0YnHxs3TcGz2J5pXl11/IncItdBFcnoq u6FL2zgXkNikHZf4AJmSmeyMQpdwysfsZduulzmXfQ+ozf0tRsHJ2F8tMP1IMRdS TknUoVfhfqDylvOxAosu7HNqrRlmTBwLqgiutYU2kzUT0m1sXOZc/A1ESPNq8vDw 1aIcW0yUc0Iahk+ewE/8L2n5X1bVkua159mzGP7WKj6yXm9uEg/0i+MS0tYXIRD1 q76n1VK5DGvn1BJU1GHwBwZjplumPITRW1WpiBwJ5ZegD6rFMqYaeBCUjzrPeZmQ IaxjRb9fF0oXcDLhhgA5O4VJrSKLQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrgeeggddvjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkjghfggfgtgesthfuredttddtvdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedugefgvdefudfftdefgeelgffhueekgfffhfeujedtteeutdejueei iedvffegheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 22 Nov 2021 06:23:07 -0500 (EST) From: Thomas Monjalon To: Elena Agostini Cc: dev@dpdk.org Subject: Re: [PATCH v3] gpudev: manage NULL pointer Date: Mon, 22 Nov 2021 12:23:05 +0100 Message-ID: <3103480.BfGS6plSxf@thomas> In-Reply-To: <20211122182423.5581-1-eagostini@nvidia.com> References: <20211118203354.25355-1-eagostini@nvidia.com> <20211122182423.5581-1-eagostini@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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 22/11/2021 19:24, eagostini@nvidia.com: > From: Elena Agostini > > gpudev free and unregister functions return gracefully if input pointer is NULL We could add that the API doc was indicating NULL as a no-op accepted value. Another explanation to add: cuda driver checks are removed because redundant with the checks added in gpudev library. > Fixes: 818a067baf90 ("gpudev: manage NULL pointer") It should be: Fixes: e818c4e2bf50 ("gpudev: add memory API") > > Signed-off-by: Elena Agostini > --- > drivers/gpu/cuda/cuda.c | 6 ------ > lib/gpudev/gpudev.c | 6 ++++++ > 2 files changed, 6 insertions(+), 6 deletions(-) [...] > --- 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); I think we should keep this check first. > @@ -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); Same here. There is third function where NULL should be accepted: rte_gpu_mem_register