EDAC: Use edac_debugfs_remove_recursive()
authorTan Xiaojun <tanxiaojun@huawei.com>
Wed, 14 Oct 2015 01:49:24 +0000 (09:49 +0800)
committerBorislav Petkov <bp@suse.de>
Wed, 14 Oct 2015 16:50:32 +0000 (18:50 +0200)
debugfs_remove() is used to remove a file or a directory from the
debugfs filesystem, but mci->debugfs might not empty.

This can be triggered by the following sequence:

1) Enable CONFIG_EDAC_DEBUG
2) insmod an EDAC module (like i3000_edac or similar)
3) rmmod this module
4) we can see files remaining under <debugfs_mountpoint>/edac/ like
   "fake_inject", for example.

Removing edac_core then, causes a NULL pointer dereference.

Reported-by: Yun Wu (Abel) <wuyun.wu@huawei.com>
Signed-off-by: Tan Xiaojun <tanxiaojun@huawei.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Link: http://lkml.kernel.org/r/1444787364-104353-1-git-send-email-tanxiaojun@huawei.com
Signed-off-by: Borislav Petkov <bp@suse.de>
drivers/edac/debugfs.c
drivers/edac/edac_mc_sysfs.c

index 4864703115ccde194c9e0cffd55fc446935e0844..54d2f668cb0ae09cccaf559fb199e18dda9b95bc 100644 (file)
@@ -98,7 +98,7 @@ int edac_create_debugfs_nodes(struct mem_ctl_info *mci)
        mci->debugfs = parent;
        return 0;
 nomem:
-       debugfs_remove(mci->debugfs);
+       edac_debugfs_remove_recursive(mci->debugfs);
        return -ENOMEM;
 }
 
index 3929391f0b920e9feaaaea9da5054099272b1986..a75acea0f674ed7ca9101ca7ce8a65e5b0961905 100644 (file)
@@ -976,7 +976,7 @@ void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci)
        edac_dbg(0, "\n");
 
 #ifdef CONFIG_EDAC_DEBUG
-       debugfs_remove(mci->debugfs);
+       edac_debugfs_remove_recursive(mci->debugfs);
 #endif
 #ifdef CONFIG_EDAC_LEGACY_SYSFS
        edac_delete_csrow_objects(mci);