Patch "NTB: amd: Fix error handling in amd_ntb_pci_driver_init()" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    NTB: amd: Fix error handling in amd_ntb_pci_driver_init()

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ntb-amd-fix-error-handling-in-amd_ntb_pci_driver_ini.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit acb70e7fad57fad2b84b9cef5f7abdbafd1deea1
Author: Yuan Can <yuancan@xxxxxxxxxx>
Date:   Sat Nov 5 09:43:09 2022 +0000

    NTB: amd: Fix error handling in amd_ntb_pci_driver_init()
    
    [ Upstream commit 98af0a33c1101c29b3ce4f0cf4715fd927c717f9 ]
    
    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: a1b3695820aa ("NTB: Add support for AMD PCI-Express Non-Transparent Bridge")
    Signed-off-by: Yuan Can <yuancan@xxxxxxxxxx>
    Signed-off-by: Jon Mason <jdmason@xxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c
index 71428d8cbcfc5..ac401ad7884a6 100644
--- a/drivers/ntb/hw/amd/ntb_hw_amd.c
+++ b/drivers/ntb/hw/amd/ntb_hw_amd.c
@@ -1344,12 +1344,17 @@ static struct pci_driver amd_ntb_pci_driver = {
 
 static int __init amd_ntb_pci_driver_init(void)
 {
+	int ret;
 	pr_info("%s %s\n", NTB_DESC, NTB_VER);
 
 	if (debugfs_initialized())
 		debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
 
-	return pci_register_driver(&amd_ntb_pci_driver);
+	ret = pci_register_driver(&amd_ntb_pci_driver);
+	if (ret)
+		debugfs_remove_recursive(debugfs_dir);
+
+	return ret;
 }
 module_init(amd_ntb_pci_driver_init);
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux