Patch "serial: 8250_bcm7271: Fix error handling in brcmuart_init()" has been added to the 6.0-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

    serial: 8250_bcm7271: Fix error handling in brcmuart_init()

to the 6.0-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:
     serial-8250_bcm7271-fix-error-handling-in-brcmuart_i.patch
and it can be found in the queue-6.0 subdirectory.

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



commit 1dcf33a7096e6b2ec7db6f23558fceeaea731dca
Author: Yuan Can <yuancan@xxxxxxxxxx>
Date:   Wed Nov 9 07:21:10 2022 +0000

    serial: 8250_bcm7271: Fix error handling in brcmuart_init()
    
    [ Upstream commit 6a3ff858915fa8ca36c7eb02c87c9181ae2fc333 ]
    
    A problem about 8250_bcm7271 create debugfs failed is triggered with the
    following log given:
    
     [  324.516635] debugfs: Directory 'bcm7271-uart' with parent '/' already present!
    
    The reason is that brcmuart_init() returns platform_driver_register()
    directly without checking its return value, if platform_driver_register()
    failed, it returns without destroy the newly created debugfs, resulting
    the debugfs of 8250_bcm7271 can never be created later.
    
     brcmuart_init()
       debugfs_create_dir() # create debugfs directory
       platform_driver_register()
         driver_register()
           bus_add_driver()
             priv = kzalloc(...) # OOM happened
       # return without destroy debugfs directory
    
    Fix by removing debugfs when platform_driver_register() returns error.
    
    Fixes: 41a469482de2 ("serial: 8250: Add new 8250-core based Broadcom STB driver")
    Signed-off-by: Yuan Can <yuancan@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20221109072110.117291-2-yuancan@xxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/tty/serial/8250/8250_bcm7271.c b/drivers/tty/serial/8250/8250_bcm7271.c
index 8efdc271eb75..5e0ffd6c4789 100644
--- a/drivers/tty/serial/8250/8250_bcm7271.c
+++ b/drivers/tty/serial/8250/8250_bcm7271.c
@@ -1212,9 +1212,17 @@ static struct platform_driver brcmuart_platform_driver = {
 
 static int __init brcmuart_init(void)
 {
+	int ret;
+
 	brcmuart_debugfs_root = debugfs_create_dir(
 		brcmuart_platform_driver.driver.name, NULL);
-	return platform_driver_register(&brcmuart_platform_driver);
+	ret = platform_driver_register(&brcmuart_platform_driver);
+	if (ret) {
+		debugfs_remove_recursive(brcmuart_debugfs_root);
+		return ret;
+	}
+
+	return 0;
 }
 module_init(brcmuart_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