* [PATCH 1/2] PCI: cadence: Set .owner = THIS_MODULE in cdns_pcie_epc_ops
2026-12-03 17:16 [PATCH 0/2] PCI: endpoint: Set .owner = THIS_MODULE in struct pci_epc_ops Ian Rogers
@ 2026-12-03 17:16 ` Ian Rogers
2026-12-03 18:33 ` sashiko-bot
2026-12-03 17:16 ` [PATCH 2/2] PCI: endpoint: Set .owner = THIS_MODULE in remaining pci_epc_ops Ian Rogers
2026-12-03 18:47 ` [PATCH 0/2] PCI: endpoint: Set .owner = THIS_MODULE in struct pci_epc_ops sashiko-bot
2 siblings, 1 reply; 5+ messages in thread
From: Ian Rogers @ 2026-12-03 17:16 UTC (permalink / raw)
To: Manivannan Sadhasivam, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bjorn Helgaas
Cc: Rob Herring, Nathan Chancellor, linux-pci, llvm, linux-kernel,
Ian Rogers, Aksh Garg, Cyrille Pitchen
pci_epc_get() calls try_module_get(epc->ops->owner) and pci_epc_put()
calls module_put(epc->ops->owner), while __pci_epc_create() ignores its
owner parameter because epc->ops is const struct pci_epc_ops *. Because
pcie-cadence-ep can be built as a module (CONFIG_PCIE_CADENCE_EP),
omitting .owner leaves the module unpinned while an endpoint controller
reference is held.
Set .owner = THIS_MODULE in cdns_pcie_epc_ops, found with Clang's
require_explicit_initialization attribute.
Fixes: 37dddf14f1ae ("PCI: cadence: Add EndPoint Controller driver for Cadence PCIe controller")
Signed-off-by: Ian Rogers <irogers@google.com>
---
drivers/pci/controller/cadence/pcie-cadence-ep.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/pci/controller/cadence/pcie-cadence-ep.c b/drivers/pci/controller/cadence/pcie-cadence-ep.c
index a967f7762283..eda5e2da90db 100644
--- a/drivers/pci/controller/cadence/pcie-cadence-ep.c
+++ b/drivers/pci/controller/cadence/pcie-cadence-ep.c
@@ -648,6 +648,7 @@ static const struct pci_epc_ops cdns_pcie_epc_ops = {
.map_msi_irq = cdns_pcie_ep_map_msi_irq,
.start = cdns_pcie_ep_start,
.get_features = cdns_pcie_ep_get_features,
+ .owner = THIS_MODULE,
};
void cdns_pcie_ep_disable(struct cdns_pcie_ep *ep)
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2] PCI: endpoint: Set .owner = THIS_MODULE in remaining pci_epc_ops
2026-12-03 17:16 [PATCH 0/2] PCI: endpoint: Set .owner = THIS_MODULE in struct pci_epc_ops Ian Rogers
2026-12-03 17:16 ` [PATCH 1/2] PCI: cadence: Set .owner = THIS_MODULE in cdns_pcie_epc_ops Ian Rogers
@ 2026-12-03 17:16 ` Ian Rogers
2026-12-03 18:47 ` [PATCH 0/2] PCI: endpoint: Set .owner = THIS_MODULE in struct pci_epc_ops sashiko-bot
2 siblings, 0 replies; 5+ messages in thread
From: Ian Rogers @ 2026-12-03 17:16 UTC (permalink / raw)
To: Manivannan Sadhasivam, Lorenzo Pieralisi,
Krzysztof Wilczyński, Bjorn Helgaas
Cc: Rob Herring, Nathan Chancellor, linux-pci, llvm, linux-kernel,
Ian Rogers, Jingoo Han, Marek Vasut, Yoshihiro Shimoda,
Geert Uytterhoeven, Magnus Damm, Shawn Lin, Heiko Stuebner,
linux-renesas-soc, linux-rockchip, linux-arm-kernel
pcie-designware-ep, pcie-rcar-ep, and pcie-rockchip-ep are currently
bool Kconfig options (where THIS_MODULE is NULL), so omitting .owner in
their struct pci_epc_ops definitions does not affect runtime module
reference counting today.
Initialize .owner = THIS_MODULE in all three for consistency across all
struct pci_epc_ops definitions and to prepare for annotating
pci_epc_ops::owner with Clang's require_explicit_initialization
attribute.
Signed-off-by: Ian Rogers <irogers@google.com>
---
drivers/pci/controller/dwc/pcie-designware-ep.c | 2 ++
drivers/pci/controller/pcie-rcar-ep.c | 2 ++
drivers/pci/controller/pcie-rockchip-ep.c | 2 ++
3 files changed, 6 insertions(+)
diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
index e6060bb0bbbd..d5223597b5c9 100644
--- a/drivers/pci/controller/dwc/pcie-designware-ep.c
+++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
@@ -8,6 +8,7 @@
#include <linux/align.h>
#include <linux/bitfield.h>
+#include <linux/module.h>
#include <linux/of.h>
#include <linux/overflow.h>
#include <linux/platform_device.h>
@@ -949,6 +950,7 @@ static const struct pci_epc_ops epc_ops = {
.get_features = dw_pcie_ep_get_features,
.get_aux_resources_count = dw_pcie_ep_get_aux_resources_count,
.get_aux_resources = dw_pcie_ep_get_aux_resources,
+ .owner = THIS_MODULE,
};
/**
diff --git a/drivers/pci/controller/pcie-rcar-ep.c b/drivers/pci/controller/pcie-rcar-ep.c
index e33c66caa1a6..b9df4699178c 100644
--- a/drivers/pci/controller/pcie-rcar-ep.c
+++ b/drivers/pci/controller/pcie-rcar-ep.c
@@ -7,6 +7,7 @@
*/
#include <linux/delay.h>
+#include <linux/module.h>
#include <linux/of_address.h>
#include <linux/of_platform.h>
#include <linux/pci.h>
@@ -463,6 +464,7 @@ static const struct pci_epc_ops rcar_pcie_epc_ops = {
.start = rcar_pcie_ep_start,
.stop = rcar_pcie_ep_stop,
.get_features = rcar_pcie_ep_get_features,
+ .owner = THIS_MODULE,
};
static const struct of_device_id rcar_pcie_ep_of_match[] = {
diff --git a/drivers/pci/controller/pcie-rockchip-ep.c b/drivers/pci/controller/pcie-rockchip-ep.c
index a20536d50c9c..4a6c9dfeab83 100644
--- a/drivers/pci/controller/pcie-rockchip-ep.c
+++ b/drivers/pci/controller/pcie-rockchip-ep.c
@@ -14,6 +14,7 @@
#include <linux/iopoll.h>
#include <linux/kernel.h>
#include <linux/irq.h>
+#include <linux/module.h>
#include <linux/of.h>
#include <linux/pci-epc.h>
#include <linux/platform_device.h>
@@ -704,6 +705,7 @@ static const struct pci_epc_ops rockchip_pcie_epc_ops = {
.start = rockchip_pcie_ep_start,
.stop = rockchip_pcie_ep_stop,
.get_features = rockchip_pcie_ep_get_features,
+ .owner = THIS_MODULE,
};
static int rockchip_pcie_ep_get_resources(struct rockchip_pcie *rockchip,
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread