DPDK patches and discussions
 help / color / mirror / Atom feed
From: dapengx.yu@intel.com
To: Qiming Yang <qiming.yang@intel.com>, Qi Zhang <qi.z.zhang@intel.com>
Cc: dev@dpdk.org, haiyue.wang@intel.com,
	Dapeng Yu <dapengx.yu@intel.com>,
	stable@dpdk.org
Subject: [dpdk-dev] [PATCH v3] net/ice: fix representor port segmentation fault
Date: Tue,  7 Sep 2021 10:00:33 +0800	[thread overview]
Message-ID: <20210907020033.2113437-1-dapengx.yu@intel.com> (raw)
In-Reply-To: <20210903054140.1530911-1-dapengx.yu@intel.com>

From: Dapeng Yu <dapengx.yu@intel.com>

If DCF representor port is closed after DCF port is closed, there will
be segmentation fault because representor accesses the released resource
of DCF port.

This patch checks if the resource is present before accessing.

Fixes: 5674465a32c8 ("net/ice: add DCF VLAN handling")
Cc: stable@dpdk.org

Signed-off-by: Dapeng Yu <dapengx.yu@intel.com>
---
V2:
 * Remove (void) to make code clean.
V3:
 * Only check resource accessibility but not release it.
---
 drivers/net/ice/ice_dcf_vf_representor.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ice/ice_dcf_vf_representor.c b/drivers/net/ice/ice_dcf_vf_representor.c
index 970461f3e9..b547c42f91 100644
--- a/drivers/net/ice/ice_dcf_vf_representor.c
+++ b/drivers/net/ice/ice_dcf_vf_representor.c
@@ -114,6 +114,11 @@ ice_dcf_vf_repr_hw(struct ice_dcf_vf_repr *repr)
 	struct ice_dcf_adapter *dcf_adapter =
 			repr->dcf_eth_dev->data->dev_private;
 
+	if (!dcf_adapter) {
+		PMD_DRV_LOG(ERR, "DCF for VF representor has been released\n");
+		return NULL;
+	}
+
 	return &dcf_adapter->real_hw;
 }
 
@@ -124,6 +129,9 @@ ice_dcf_vf_repr_dev_info_get(struct rte_eth_dev *dev,
 	struct ice_dcf_vf_repr *repr = dev->data->dev_private;
 	struct ice_dcf_hw *dcf_hw = ice_dcf_vf_repr_hw(repr);
 
+	if (!dcf_hw)
+		return -EIO;
+
 	dev_info->device = dev->device;
 	dev_info->max_mac_addrs = 1;
 	dev_info->max_rx_queues = dcf_hw->vsi_res->num_queue_pairs;
-- 
2.27.0


  reply	other threads:[~2021-09-07  2:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-02  9:44 [dpdk-dev] [PATCH] " dapengx.yu
2021-09-02 14:45 ` Wang, Haiyue
2021-09-03  3:08   ` Yu, DapengX
2021-09-03  4:37     ` Wang, Haiyue
2021-09-03  5:41 ` [dpdk-dev] [PATCH v2] " dapengx.yu
2021-09-07  2:00   ` dapengx.yu [this message]
2021-09-13  5:46     ` [dpdk-dev] [PATCH v3] " Wang, Haiyue
2021-09-13  5:50       ` Zhang, Qi Z

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=20210907020033.2113437-1-dapengx.yu@intel.com \
    --to=dapengx.yu@intel.com \
    --cc=dev@dpdk.org \
    --cc=haiyue.wang@intel.com \
    --cc=qi.z.zhang@intel.com \
    --cc=qiming.yang@intel.com \
    --cc=stable@dpdk.org \
    /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).