Fix debugfs_create_file's error checking method for arch/sh/mm/
authorZhaolei <zhaolei@cn.fujitsu.com>
Fri, 17 Oct 2008 11:25:09 +0000 (19:25 +0800)
committerPaul Mundt <lethal@linux-sh.org>
Mon, 20 Oct 2008 01:40:21 +0000 (10:40 +0900)
debugfs_create_file() returns NULL if an error occurs, returns -ENODEV
when debugfs is not enabled in the kernel.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/mm/cache-debugfs.c
arch/sh/mm/pmb.c

index 0e189ccd4a77a7ce7462f9eb863409d419a71150..5ba067b2659109caf9d013e79d59e91c4f5278eb 100644 (file)
@@ -130,12 +130,18 @@ static int __init cache_debugfs_init(void)
        dcache_dentry = debugfs_create_file("dcache", S_IRUSR, sh_debugfs_root,
                                            (unsigned int *)CACHE_TYPE_DCACHE,
                                            &cache_debugfs_fops);
+       if (!dcache_dentry)
+               return -ENOMEM;
        if (IS_ERR(dcache_dentry))
                return PTR_ERR(dcache_dentry);
 
        icache_dentry = debugfs_create_file("icache", S_IRUSR, sh_debugfs_root,
                                            (unsigned int *)CACHE_TYPE_ICACHE,
                                            &cache_debugfs_fops);
+       if (!icache_dentry) {
+               debugfs_remove(dcache_dentry);
+               return -ENOMEM;
+       }
        if (IS_ERR(icache_dentry)) {
                debugfs_remove(dcache_dentry);
                return PTR_ERR(icache_dentry);
index cef727669c8759dde6ce20ceb9ecc138d71a28bb..84241676265e61455f4e9579f7cf41810601f1e9 100644 (file)
@@ -394,6 +394,8 @@ static int __init pmb_debugfs_init(void)
 
        dentry = debugfs_create_file("pmb", S_IFREG | S_IRUGO,
                                     sh_debugfs_root, NULL, &pmb_debugfs_fops);
+       if (!dentry)
+               return -ENOMEM;
        if (IS_ERR(dentry))
                return PTR_ERR(dentry);