Patch "i2c: npcm7xx: Fix error handling in npcm_i2c_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

    i2c: npcm7xx: Fix error handling in npcm_i2c_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:
     i2c-npcm7xx-fix-error-handling-in-npcm_i2c_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 fd10d5f5bd503169c9481a237b5a7d5634691c7a
Author: Yuan Can <yuancan@xxxxxxxxxx>
Date:   Wed Nov 9 11:22:50 2022 +0000

    i2c: npcm7xx: Fix error handling in npcm_i2c_init()
    
    [ Upstream commit 145900cf91c4b32ac05dbc8675a0c7f4a278749d ]
    
    A problem about i2c-npcm7xx create debugfs failed is triggered with the
    following log given:
    
     [  173.827310] debugfs: Directory 'npcm_i2c' with parent '/' already present!
    
    The reason is that npcm_i2c_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 npcm_i2c can never be created later.
    
     npcm_i2c_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: 56a1485b102e ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver")
    Signed-off-by: Yuan Can <yuancan@xxxxxxxxxx>
    Reviewed-by: Tali Perry <tali.perry@xxxxxxxxxxx>
    Signed-off-by: Wolfram Sang <wsa@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c
index 31e3d2c9d6bc..c1b679737240 100644
--- a/drivers/i2c/busses/i2c-npcm7xx.c
+++ b/drivers/i2c/busses/i2c-npcm7xx.c
@@ -2362,8 +2362,17 @@ static struct platform_driver npcm_i2c_bus_driver = {
 
 static int __init npcm_i2c_init(void)
 {
+	int ret;
+
 	npcm_i2c_debugfs_dir = debugfs_create_dir("npcm_i2c", NULL);
-	return platform_driver_register(&npcm_i2c_bus_driver);
+
+	ret = platform_driver_register(&npcm_i2c_bus_driver);
+	if (ret) {
+		debugfs_remove_recursive(npcm_i2c_debugfs_dir);
+		return ret;
+	}
+
+	return 0;
 }
 module_init(npcm_i2c_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