提交 7711cbb4 编写于 作者: Y Yoshihiro Shimoda 提交者: Lorenzo Pieralisi

PCI: endpoint: Fix WARN() when an endpoint driver is removed

Since there is no release callback defined for the PCI EPC device,
the below warning is thrown by driver core when a PCI endpoint driver is
removed:

  Device 'e65d0000.pcie-ep' does not have a release() function, it is broken and must be fixed. See Documentation/core-api/kobject.rst.
  WARNING: CPU: 0 PID: 139 at drivers/base/core.c:2232 device_release+0x78/0x8c

Hence, add the release callback and also move the kfree(epc) from
pci_epc_destroy() so that the epc memory is freed when all references are
dropped.

Link: https://lore.kernel.org/r/20220623003817.298173-1-yoshihiro.shimoda.uh@renesas.comTested-by: NVidya Sagar <vidyas@nvidia.com>
Signed-off-by: NYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: NLorenzo Pieralisi <lpieralisi@kernel.org>
Reviewed-by: NManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
上级 9abf2313
...@@ -724,7 +724,6 @@ void pci_epc_destroy(struct pci_epc *epc) ...@@ -724,7 +724,6 @@ void pci_epc_destroy(struct pci_epc *epc)
{ {
pci_ep_cfs_remove_epc_group(epc->group); pci_ep_cfs_remove_epc_group(epc->group);
device_unregister(&epc->dev); device_unregister(&epc->dev);
kfree(epc);
} }
EXPORT_SYMBOL_GPL(pci_epc_destroy); EXPORT_SYMBOL_GPL(pci_epc_destroy);
...@@ -746,6 +745,11 @@ void devm_pci_epc_destroy(struct device *dev, struct pci_epc *epc) ...@@ -746,6 +745,11 @@ void devm_pci_epc_destroy(struct device *dev, struct pci_epc *epc)
} }
EXPORT_SYMBOL_GPL(devm_pci_epc_destroy); EXPORT_SYMBOL_GPL(devm_pci_epc_destroy);
static void pci_epc_release(struct device *dev)
{
kfree(to_pci_epc(dev));
}
/** /**
* __pci_epc_create() - create a new endpoint controller (EPC) device * __pci_epc_create() - create a new endpoint controller (EPC) device
* @dev: device that is creating the new EPC * @dev: device that is creating the new EPC
...@@ -779,6 +783,7 @@ __pci_epc_create(struct device *dev, const struct pci_epc_ops *ops, ...@@ -779,6 +783,7 @@ __pci_epc_create(struct device *dev, const struct pci_epc_ops *ops,
device_initialize(&epc->dev); device_initialize(&epc->dev);
epc->dev.class = pci_epc_class; epc->dev.class = pci_epc_class;
epc->dev.parent = dev; epc->dev.parent = dev;
epc->dev.release = pci_epc_release;
epc->ops = ops; epc->ops = ops;
ret = dev_set_name(&epc->dev, "%s", dev_name(dev)); ret = dev_set_name(&epc->dev, "%s", dev_name(dev));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册