• Yuan Can's avatar
    ntb: intel: Fix error handling in intel_ntb_pci_driver_init() · 4c3c796a
    Yuan Can authored
    A problem about ntb_hw_intel create debugfs failed is triggered with the
    following log given:
    
     [  273.112733] Intel(R) PCI-E Non-Transparent Bridge Driver 2.0
     [  273.115342] debugfs: Directory 'ntb_hw_intel' with parent '/' already present!
    
    The reason is that intel_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_intel can never be created later.
    
     intel_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: e26a5843 ("NTB: Split ntb_hw_intel and ntb_transport drivers")
    Signed-off-by: default avatarYuan Can <yuancan@huawei.com>
    Acked-by: default avatarDave Jiang <dave.jiang@intel.com>
    Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
    4c3c796a
ntb_hw_gen1.c 56.1 KB