History

eeprom: idt_89hpesx: Fix error handling in idt_init()

A problem about idt_89hpesx create debugfs failed is triggered with the following log given: [ 4973.269647] debugfs: Directory 'idt_csr' with parent '/' already present! The reason is that idt_init() returns i2c_add_driver() directly without checking its return value, if i2c_add_driver() failed, it returns without destroy the newly created debugfs, resulting the debugfs of idt_csr can never be created later. idt_init() debugfs_create_dir() # create debugfs directory i2c_add_driver() driver_register() bus_add_driver() priv = kzalloc(...) # OOM happened # return without destroy debugfs directory Fix by removing debugfs when i2c_add_driver() returns error.

Yuan Can committed 4 years ago

Commit d717a3a1 parent 0eb468b1 file · +9 −1Browse files

Unified · Split

drivers/misc/eeprom/idt_89hpesx.c+9−1
@@ -1566,12 +1566,20 @@ static struct i2c_driver idt_driver = { · 1565 unmodified lines
1566 */1566 */
1567static int __init idt_init(void)1567static int __init idt_init(void)
1568{1568{
1569 int ret;
1570
1569 /* Create Debugfs directory first */1571 /* Create Debugfs directory first */
1570 if (debugfs_initialized())1572 if (debugfs_initialized())
1571 csr_dbgdir = debugfs_create_dir("idt_csr", NULL);1573 csr_dbgdir = debugfs_create_dir("idt_csr", NULL);
1572 1574
1573 /* Add new i2c-device driver */1575 /* Add new i2c-device driver */
1574 return i2c_add_driver(&idt_driver);1576 ret = i2c_add_driver(&idt_driver);
1577 if (ret) {
1578 debugfs_remove_recursive(csr_dbgdir);
1579 return ret;
1580 }
1581
1582 return 0;
1575}1583}
1576module_init(idt_init);1584module_init(idt_init);
1577 1585

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t