Patch "ntb: idt: Fix error handling in idt_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: idt: Fix error handling in idt_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-idt-fix-error-handling-in-idt_pci_driver_init.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 901c9a0805498149af8ac8ca51b1ca8cba34d3d2
Author: Yuan Can <yuancan@xxxxxxxxxx>
Date:   Sat Nov 5 09:43:01 2022 +0000

    ntb: idt: Fix error handling in idt_pci_driver_init()
    
    [ Upstream commit c012968259b451dc4db407f2310fe131eaefd800 ]
    
    A problem about ntb_hw_idt create debugfs failed is triggered with the
    following log given:
    
     [ 1236.637636] IDT PCI-E Non-Transparent Bridge Driver 2.0
     [ 1236.639292] debugfs: Directory 'ntb_hw_idt' with parent '/' already present!
    
    The reason is that idt_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_idt can never be created later.
    
     idt_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: bf2a952d31d2 ("NTB: Add IDT 89HPESxNTx PCIe-switches support")
    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/idt/ntb_hw_idt.c b/drivers/ntb/hw/idt/ntb_hw_idt.c
index d54261f508519..99711dd0b6e8e 100644
--- a/drivers/ntb/hw/idt/ntb_hw_idt.c
+++ b/drivers/ntb/hw/idt/ntb_hw_idt.c
@@ -2902,6 +2902,7 @@ static struct pci_driver idt_pci_driver = {
 
 static int __init idt_pci_driver_init(void)
 {
+	int ret;
 	pr_info("%s %s\n", NTB_DESC, NTB_VER);
 
 	/* Create the top DebugFS directory if the FS is initialized */
@@ -2909,7 +2910,11 @@ static int __init idt_pci_driver_init(void)
 		dbgfs_topdir = debugfs_create_dir(KBUILD_MODNAME, NULL);
 
 	/* Register the NTB hardware driver to handle the PCI device */
-	return pci_register_driver(&idt_pci_driver);
+	ret = pci_register_driver(&idt_pci_driver);
+	if (ret)
+		debugfs_remove_recursive(dbgfs_topdir);
+
+	return ret;
 }
 module_init(idt_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