mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zijun Hu <zijun_hu@icloud.com>
To: "Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Kishon Vijay Abraham I" <kishon@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Frank Li" <Frank.Li@nxp.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>
Cc: "Zijun Hu" <zijun_hu@icloud.com>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Zijun Hu" <quic_zijuhu@quicinc.com>,
	stable@vger.kernel.org
Subject: [PATCH v2 2/2] PCI: endpoint: Fix API pci_epc_remove_epf() cleaning up wrong EPC of EPF
Date: Thu, 07 Nov 2024 08:53:09 +0800	[thread overview]
Message-ID: <20241107-epc_rfc-v2-2-da5b6a99a66f@quicinc.com> (raw)
In-Reply-To: <20241107-epc_rfc-v2-0-da5b6a99a66f@quicinc.com>

From: Zijun Hu <quic_zijuhu@quicinc.com>

It is wrong for pci_epc_remove_epf(..., epf, SECONDARY_INTERFACE) to
clean up @epf->epc obviously.

Fix by cleaning up @epf->sec_epc instead of @epf->epc for
SECONDARY_INTERFACE.

Fixes: 63840ff53223 ("PCI: endpoint: Add support to associate secondary EPC with EPF")
Cc: stable@vger.kernel.org
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
 drivers/pci/endpoint/pci-epc-core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c
index bcc9bc3d6df5..62f7dff43730 100644
--- a/drivers/pci/endpoint/pci-epc-core.c
+++ b/drivers/pci/endpoint/pci-epc-core.c
@@ -660,18 +660,18 @@ void pci_epc_remove_epf(struct pci_epc *epc, struct pci_epf *epf,
 	if (IS_ERR_OR_NULL(epc) || !epf)
 		return;
 
+	mutex_lock(&epc->list_lock);
 	if (type == PRIMARY_INTERFACE) {
 		func_no = epf->func_no;
 		list = &epf->list;
+		epf->epc = NULL;
 	} else {
 		func_no = epf->sec_epc_func_no;
 		list = &epf->sec_epc_list;
+		epf->sec_epc = NULL;
 	}
-
-	mutex_lock(&epc->list_lock);
 	clear_bit(func_no, &epc->function_num_map);
 	list_del(list);
-	epf->epc = NULL;
 	mutex_unlock(&epc->list_lock);
 }
 EXPORT_SYMBOL_GPL(pci_epc_remove_epf);

-- 
2.34.1


  parent reply	other threads:[~2024-11-07  0:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07  0:53 [PATCH v2 0/2] PCI: endpoint: fix bugs for both API pci_epc_destroy() and pci_epc_remove_epf() Zijun Hu
2024-11-07  0:53 ` [PATCH v2 1/2] PCI: endpoint: Fix API pci_epc_destroy() releasing domain_nr ID faults Zijun Hu
2024-11-12  7:03   ` Manivannan Sadhasivam
2024-11-12  7:18     ` quic_zijuhu
2024-11-07  0:53 ` Zijun Hu [this message]
2024-11-12  7:08   ` [PATCH v2 2/2] PCI: endpoint: Fix API pci_epc_remove_epf() cleaning up wrong EPC of EPF Manivannan Sadhasivam
2024-11-12  7:35 ` [PATCH v2 0/2] PCI: endpoint: fix bugs for both API pci_epc_destroy() and pci_epc_remove_epf() Manivannan Sadhasivam

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=20241107-epc_rfc-v2-2-da5b6a99a66f@quicinc.com \
    --to=zijun_hu@icloud.com \
    --cc=Frank.Li@nxp.com \
    --cc=bhelgaas@google.com \
    --cc=kishon@kernel.org \
    --cc=kw@linux.com \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=quic_zijuhu@quicinc.com \
    --cc=stable@vger.kernel.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

all inboxes | Powered by JetHome®