]> git.baikalelectronics.ru Git - kernel.git/commit
i2c: npcm7xx: Fix error handling in npcm_i2c_init()
authorYuan Can <yuancan@huawei.com>
Wed, 9 Nov 2022 11:22:50 +0000 (11:22 +0000)
committerWolfram Sang <wsa@kernel.org>
Sat, 12 Nov 2022 20:27:00 +0000 (21:27 +0100)
commita9b915d7bf397ca9a672a0fb202693f68970d262
treef88f2ab57476daa604f8f34afc000363f90e6828
parentdfd2bf0335fb2bf3195544c775fab6f0b6e2f418
i2c: npcm7xx: Fix error handling in npcm_i2c_init()

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: 58fafb9526b2 ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver")
Signed-off-by: Yuan Can <yuancan@huawei.com>
Reviewed-by: Tali Perry <tali.perry@nuvoton.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
drivers/i2c/busses/i2c-npcm7xx.c