From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id A68E3FF8867 for ; Wed, 29 Apr 2026 11:45:51 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0ACF74065E; Wed, 29 Apr 2026 13:45:48 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 0912B4065B for ; Wed, 29 Apr 2026 13:45:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777463146; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yYUzV/98uH8vj5dbk6TExK/YtQa9IYPlg2P5nosP5Qc=; b=cmMuk+E7tdfsUtRXeGbdtFlDzQtZSBG6vhS/GFZKinHcx9c72Gw4qbxWS9f90/4bP/NeQr PnmhT+LKBjfZEZrF+m9I7z9dQ010G/3ejgtWOwU3BZykFLPcACZmL5qjG3cEprDxbBECW8 fNweY1MzBOYroleV6kEmBbpZz4LERAc= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-100-ze8bPcVTNY-Fbaa0dNcTQg-1; Wed, 29 Apr 2026 07:45:42 -0400 X-MC-Unique: ze8bPcVTNY-Fbaa0dNcTQg-1 X-Mimecast-MFC-AGG-ID: ze8bPcVTNY-Fbaa0dNcTQg_1777463140 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 853781800358; Wed, 29 Apr 2026 11:45:40 +0000 (UTC) Received: from dmarchan.lan (unknown [10.44.33.207]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DD4E6300019F; Wed, 29 Apr 2026 11:45:37 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, stephen@networkplumber.org, bruce.richardson@intel.com, Parav Pandit , Xueming Li , Rosen Xu , Tomasz Duszynski Subject: [PATCH 05/23] drivers/bus: remove device and driver checks in plug Date: Wed, 29 Apr 2026 13:44:38 +0200 Message-ID: <20260429114503.932575-6-david.marchand@redhat.com> In-Reply-To: <20260429114503.932575-1-david.marchand@redhat.com> References: <20260429114503.932575-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: IzN4vkvwhLim7AI_NH5PNIlcoUz6vyFNSos4mKCtMyI_1777463140 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 The bus-specific device conversion macros all use container_of() to convert from a generic rte_device pointer to a bus-specific device structure. A key property of container_of() is that it does NOT return NULL when given a NULL pointer as input. Instead, it returns (NULL - offset), which is a small non-NULL pointer value. This means NULL checks on container_of() results cannot work as intended. The device parameter passed to bus probe or plug operations cannot be NULL as the caller already dereferenced the bus structure to invoke these operations. Remove redundant NULL checks on the device parameter and derived device pointers. The driver reference in the bus-specific device cannot be NULL since calling the .plug op is done after dereferencing this pointer. Signed-off-by: David Marchand --- drivers/bus/auxiliary/auxiliary_common.c | 6 ------ drivers/bus/ifpga/ifpga_bus.c | 3 --- drivers/bus/platform/platform.c | 8 +------- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/bus/auxiliary/auxiliary_common.c b/drivers/bus/auxiliary/auxiliary_common.c index 1fe0cb4d78..314361643c 100644 --- a/drivers/bus/auxiliary/auxiliary_common.c +++ b/drivers/bus/auxiliary/auxiliary_common.c @@ -81,9 +81,6 @@ rte_auxiliary_probe_one_driver(struct rte_auxiliary_driver *drv, enum rte_iova_mode iova_mode; int ret; - if (drv == NULL || dev == NULL) - return -EINVAL; - /* Check if driver supports it. */ if (!auxiliary_match(drv, dev)) /* Match of device and driver failed */ @@ -174,9 +171,6 @@ auxiliary_probe_all_drivers(struct rte_auxiliary_device *dev) struct rte_auxiliary_driver *drv; int rc; - if (dev == NULL) - return -EINVAL; - FOREACH_DRIVER_ON_AUXILIARY_BUS(drv) { if (!drv->match(dev->name)) continue; diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c index fc5308b6f4..0f331fa6dd 100644 --- a/drivers/bus/ifpga/ifpga_bus.c +++ b/drivers/bus/ifpga/ifpga_bus.c @@ -302,9 +302,6 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev) struct rte_afu_driver *drv = NULL; int ret = 0; - if (afu_dev == NULL) - return -1; - /* Check if a driver is already loaded */ if (rte_dev_is_probed(&afu_dev->device)) { IFPGA_BUS_DEBUG("Device %s is already probed", diff --git a/drivers/bus/platform/platform.c b/drivers/bus/platform/platform.c index 0345f1daf7..5cc0d69209 100644 --- a/drivers/bus/platform/platform.c +++ b/drivers/bus/platform/platform.c @@ -458,19 +458,13 @@ platform_bus_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, cons static int platform_bus_plug(struct rte_device *dev) { - struct rte_platform_device *pdev; - if (rte_bus_device_is_ignored(&platform_bus.bus, dev->name)) return -EPERM; if (!dev_is_bound_vfio_platform(dev->name)) return -EPERM; - pdev = RTE_DEV_TO_PLATFORM_DEV(dev); - if (pdev == NULL) - return -EINVAL; - - return device_attach(pdev); + return device_attach(RTE_DEV_TO_PLATFORM_DEV(dev)); } static void -- 2.53.0