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 09300A0548; Thu, 4 Nov 2021 12:04:29 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E9685426DA; Thu, 4 Nov 2021 12:04:28 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id E500E411CE; Thu, 4 Nov 2021 12:04:26 +0100 (CET) X-IronPort-AV: E=McAfee;i="6200,9189,10157"; a="255321939" X-IronPort-AV: E=Sophos;i="5.87,208,1631602800"; d="scan'208";a="255321939" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2021 04:04:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,208,1631602800"; d="scan'208";a="468426035" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.27]) by orsmga002.jf.intel.com with ESMTP; 04 Nov 2021 04:04:23 -0700 From: Ferruh Yigit To: Thomas Monjalon , Andrew Rybchenko , Stephen Hemminger , Matan Azrad Cc: Ferruh Yigit , dev@dpdk.org, stable@dpdk.org, Matan Azrad Date: Thu, 4 Nov 2021 11:04:21 +0000 Message-Id: <20211104110422.2920154-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211102234434.2639807-1-ferruh.yigit@intel.com> References: <20211102234434.2639807-1-ferruh.yigit@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] ethdev: fix crash on owner delete 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 Sender: "dev" 'eth_dev->data' can be null before ethdev allocated. The API walks through all eth devices, at least for some data can be null. Adding 'eth_dev->data' null check before accessing it. Fixes: 33c73aae32e4 ("ethdev: allow ownership operations on unused port") Cc: stable@dpdk.org Signed-off-by: Ferruh Yigit --- Cc: Matan Azrad --- lib/ethdev/rte_ethdev.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 7db84b12d03b..8e679e4003db 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -757,10 +757,13 @@ rte_eth_dev_owner_delete(const uint64_t owner_id) rte_spinlock_lock(ð_dev_shared_data->ownership_lock); if (eth_is_valid_owner_id(owner_id)) { - for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) - if (rte_eth_devices[port_id].data->owner.id == owner_id) - memset(&rte_eth_devices[port_id].data->owner, 0, + for (port_id = 0; port_id < RTE_MAX_ETHPORTS; port_id++) { + struct rte_eth_dev_data *data = + rte_eth_devices[port_id].data; + if (data != NULL && data->owner.id == owner_id) + memset(&data->owner, 0, sizeof(struct rte_eth_dev_owner)); + } RTE_ETHDEV_LOG(NOTICE, "All port owners owned by %016"PRIx64" identifier have removed\n", owner_id); -- 2.31.1