DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Thomas Monjalon <thomas@monjalon.net>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
	Stephen Hemminger <stephen@networkplumber.org>,
	Matan Azrad <matan@mellanox.com>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>,
	dev@dpdk.org, stable@dpdk.org, Matan Azrad <matan@nvidia.com>
Subject: [dpdk-dev] [PATCH] ethdev: fix crash on owner delete
Date: Thu,  4 Nov 2021 11:04:21 +0000	[thread overview]
Message-ID: <20211104110422.2920154-1-ferruh.yigit@intel.com> (raw)
In-Reply-To: <20211102234434.2639807-1-ferruh.yigit@intel.com>

'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 <ferruh.yigit@intel.com>
---
Cc: Matan Azrad <matan@nvidia.com>
---
 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(&eth_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


  parent reply	other threads:[~2021-11-04 11:04 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-29 21:47 [dpdk-dev] [RFC] ethdev: mark old ETH_LINK macros as deprecated Stephen Hemminger
2021-11-01 12:30 ` Ferruh Yigit
2021-11-02 23:44 ` [dpdk-dev] [PATCH] ethdev: mark old " Ferruh Yigit
2021-11-03  0:05   ` Stephen Hemminger
2021-11-03  9:00     ` Ferruh Yigit
2021-11-03 22:48   ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
2021-11-04 11:03     ` Ferruh Yigit
2021-11-04 12:59       ` Thomas Monjalon
2021-11-05 13:40         ` Andrew Rybchenko
2021-11-05 15:05           ` Thomas Monjalon
2021-11-05 16:26             ` Stephen Hemminger
2021-11-05 21:33               ` Ferruh Yigit
2021-11-06  7:46                 ` Thomas Monjalon
2022-01-12 14:36     ` [PATCH v3] " Ferruh Yigit
2022-01-14  6:45       ` Xia, Chenbo
2022-01-14  9:01         ` Ferruh Yigit
2021-11-04 11:04   ` Ferruh Yigit [this message]
2021-11-05  3:03     ` [dpdk-dev] [dpdk-stable] [PATCH] ethdev: fix crash on owner delete Xia, Chenbo
2021-11-05 13:16       ` Thomas Monjalon
2021-11-05 13:36         ` Andrew Rybchenko
2021-11-05 14:36           ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211104110422.2920154-1-ferruh.yigit@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=matan@mellanox.com \
    --cc=matan@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).