Merge branch 'remotes/lorenzo/pci/endpoint'

- Fix NULL pointer dereference when epc_features not implemented (Shradha
  Todi)

- Remove redundant initialization (Colin Ian King)

- Add missing destroy_workqueue() in endpoint test (Yang Yingliang)

* remotes/lorenzo/pci/endpoint:
  PCI: endpoint: Fix missing destroy_workqueue()
  PCI: endpoint: Remove redundant initialization of pointer dev
  PCI: endpoint: Fix NULL pointer dereference for ->get_features()
This commit is contained in:
Bjorn Helgaas 2021-05-04 10:43:27 -05:00
Родитель a5166a194e acaef7981a
Коммит 362e377037
2 изменённых файлов: 14 добавлений и 8 удалений

Просмотреть файл

@ -833,15 +833,18 @@ static int pci_epf_test_bind(struct pci_epf *epf)
return -EINVAL; return -EINVAL;
epc_features = pci_epc_get_features(epc, epf->func_no); epc_features = pci_epc_get_features(epc, epf->func_no);
if (epc_features) { if (!epc_features) {
linkup_notifier = epc_features->linkup_notifier; dev_err(&epf->dev, "epc_features not implemented\n");
core_init_notifier = epc_features->core_init_notifier; return -EOPNOTSUPP;
test_reg_bar = pci_epc_get_first_free_bar(epc_features);
if (test_reg_bar < 0)
return -EINVAL;
pci_epf_configure_bar(epf, epc_features);
} }
linkup_notifier = epc_features->linkup_notifier;
core_init_notifier = epc_features->core_init_notifier;
test_reg_bar = pci_epc_get_first_free_bar(epc_features);
if (test_reg_bar < 0)
return -EINVAL;
pci_epf_configure_bar(epf, epc_features);
epf_test->test_reg_bar = test_reg_bar; epf_test->test_reg_bar = test_reg_bar;
epf_test->epc_features = epc_features; epf_test->epc_features = epc_features;
@ -922,6 +925,7 @@ static int __init pci_epf_test_init(void)
ret = pci_epf_register_driver(&test_driver); ret = pci_epf_register_driver(&test_driver);
if (ret) { if (ret) {
destroy_workqueue(kpcitest_workqueue);
pr_err("Failed to register pci epf test driver --> %d\n", ret); pr_err("Failed to register pci epf test driver --> %d\n", ret);
return ret; return ret;
} }
@ -932,6 +936,8 @@ module_init(pci_epf_test_init);
static void __exit pci_epf_test_exit(void) static void __exit pci_epf_test_exit(void)
{ {
if (kpcitest_workqueue)
destroy_workqueue(kpcitest_workqueue);
pci_epf_unregister_driver(&test_driver); pci_epf_unregister_driver(&test_driver);
} }
module_exit(pci_epf_test_exit); module_exit(pci_epf_test_exit);

Просмотреть файл

@ -113,7 +113,7 @@ EXPORT_SYMBOL_GPL(pci_epf_bind);
void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno bar, void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno bar,
enum pci_epc_interface_type type) enum pci_epc_interface_type type)
{ {
struct device *dev = epf->epc->dev.parent; struct device *dev;
struct pci_epf_bar *epf_bar; struct pci_epf_bar *epf_bar;
struct pci_epc *epc; struct pci_epc *epc;