eeprom: idt_89hpesx: Fix error handling in idt_init()
[linux-2.6-microblaze.git] / drivers / misc / eeprom / idt_89hpesx.c
index 4e07ee9..7075d0b 100644 (file)
@@ -1566,12 +1566,20 @@ static struct i2c_driver idt_driver = {
  */
 static int __init idt_init(void)
 {
+       int ret;
+
        /* Create Debugfs directory first */
        if (debugfs_initialized())
                csr_dbgdir = debugfs_create_dir("idt_csr", NULL);
 
        /* Add new i2c-device driver */
-       return i2c_add_driver(&idt_driver);
+       ret = i2c_add_driver(&idt_driver);
+       if (ret) {
+               debugfs_remove_recursive(csr_dbgdir);
+               return ret;
+       }
+
+       return 0;
 }
 module_init(idt_init);