linux/drivers/ntb
Yuan Can 98af0a33c1 NTB: amd: Fix error handling in amd_ntb_pci_driver_init()
A problem about ntb_hw_amd create debugfs failed is triggered with the
following log given:

 [  618.431232] AMD(R) PCI-E Non-Transparent Bridge Driver 1.0
 [  618.433284] debugfs: Directory 'ntb_hw_amd' with parent '/' already present!

The reason is that amd_ntb_pci_driver_init() returns pci_register_driver()
directly without checking its return value, if pci_register_driver()
failed, it returns without destroy the newly created debugfs, resulting
the debugfs of ntb_hw_amd can never be created later.

 amd_ntb_pci_driver_init()
   debugfs_create_dir() # create debugfs directory
   pci_register_driver()
     driver_register()
       bus_add_driver()
         priv = kzalloc(...) # OOM happened
   # return without destroy debugfs directory

Fix by removing debugfs when pci_register_driver() returns error.

Fixes: a1b3695820 ("NTB: Add support for AMD PCI-Express Non-Transparent Bridge")
Signed-off-by: Yuan Can <yuancan@huawei.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
2023-07-08 10:51:55 -04:00
..
hw NTB: amd: Fix error handling in amd_ntb_pci_driver_init() 2023-07-08 10:51:55 -04:00
test NTB: ntb_tool: uninitialized heap data in tool_fn_write() 2022-08-09 11:54:41 -04:00
core.c bus: Make remove callback return void 2021-07-21 11:53:42 +02:00
Kconfig New feature to add support for NTB virtual MSI interrupts, the ability 2019-07-21 09:46:59 -07:00
Makefile New feature to add support for NTB virtual MSI interrupts, the ability 2019-07-21 09:46:59 -07:00
msi.c NTB/msi: Use struct_size() helper in devm_kzalloc() 2022-01-23 16:15:15 -05:00
ntb_transport.c bus: Make remove callback return void 2021-07-21 11:53:42 +02:00