mm: no need to check return value of debugfs_create functions
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 5 Mar 2019 23:46:09 +0000 (15:46 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 6 Mar 2019 05:07:17 +0000 (21:07 -0800)
When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Link: http://lkml.kernel.org/r/20190122152151.16139-14-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: David Rientjes <rientjes@google.com>
Cc: Laura Abbott <labbott@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/cma_debug.c
mm/failslab.c
mm/gup_benchmark.c
mm/huge_memory.c
mm/memblock.c
mm/memory.c
mm/page_alloc.c
mm/page_owner.c
mm/vmstat.c

index ad6723e9d110a9053c454e6aa3d0717364f9c587..b55f28fbe831a914cb0d0b0a2b0deb336516c3e6 100644 (file)
@@ -191,8 +191,6 @@ static int __init cma_debugfs_init(void)
        int i;
 
        cma_debugfs_root = debugfs_create_dir("cma", NULL);
-       if (!cma_debugfs_root)
-               return -ENOMEM;
 
        for (i = 0; i < cma_area_count; i++)
                cma_debugfs_add_one(&cma_areas[i], i);
index b135ebb88b6f729e145430999591beb3db2371d2..ec5aad211c5be978332dd59682f9536cb2f54f74 100644 (file)
@@ -48,18 +48,12 @@ static int __init failslab_debugfs_init(void)
        if (IS_ERR(dir))
                return PTR_ERR(dir);
 
-       if (!debugfs_create_bool("ignore-gfp-wait", mode, dir,
-                               &failslab.ignore_gfp_reclaim))
-               goto fail;
-       if (!debugfs_create_bool("cache-filter", mode, dir,
-                               &failslab.cache_filter))
-               goto fail;
+       debugfs_create_bool("ignore-gfp-wait", mode, dir,
+                           &failslab.ignore_gfp_reclaim);
+       debugfs_create_bool("cache-filter", mode, dir,
+                           &failslab.cache_filter);
 
        return 0;
-fail:
-       debugfs_remove_recursive(dir);
-
-       return -ENOMEM;
 }
 
 late_initcall(failslab_debugfs_init);
index 5b42d3d4b60aa3a921002abf8f2872bc6e0764f8..6c0279e70cc479221adaf69142993c3e54557235 100644 (file)
@@ -122,12 +122,8 @@ static const struct file_operations gup_benchmark_fops = {
 
 static int gup_benchmark_init(void)
 {
-       void *ret;
-
-       ret = debugfs_create_file_unsafe("gup_benchmark", 0600, NULL, NULL,
-                       &gup_benchmark_fops);
-       if (!ret)
-               pr_warn("Failed to create gup_benchmark in debugfs");
+       debugfs_create_file_unsafe("gup_benchmark", 0600, NULL, NULL,
+                                  &gup_benchmark_fops);
 
        return 0;
 }
index d066f7ca1ee8c7f7582ebcc1cd46c8f21e9c9206..af07527cd971d4eba9cf0f1d457e4306e703d269 100644 (file)
@@ -2887,12 +2887,8 @@ DEFINE_SIMPLE_ATTRIBUTE(split_huge_pages_fops, NULL, split_huge_pages_set,
 
 static int __init split_huge_pages_debugfs(void)
 {
-       void *ret;
-
-       ret = debugfs_create_file("split_huge_pages", 0200, NULL, NULL,
-                       &split_huge_pages_fops);
-       if (!ret)
-               pr_warn("Failed to create split_huge_pages in debugfs");
+       debugfs_create_file("split_huge_pages", 0200, NULL, NULL,
+                           &split_huge_pages_fops);
        return 0;
 }
 late_initcall(split_huge_pages_debugfs);
index ea31045ba70423d128575ab7e9e182a40bea425f..470601115892740fad5e687a35c929d5a43ea97f 100644 (file)
@@ -2005,8 +2005,7 @@ DEFINE_SHOW_ATTRIBUTE(memblock_debug);
 static int __init memblock_init_debugfs(void)
 {
        struct dentry *root = debugfs_create_dir("memblock", NULL);
-       if (!root)
-               return -ENXIO;
+
        debugfs_create_file("memory", 0444, root,
                            &memblock.memory, &memblock_debug_fops);
        debugfs_create_file("reserved", 0444, root,
index 79e0173a7d70ea325531716a3804a0ab09a3a70c..6aff43171a7bef751babc14f9a519b993f2ff575 100644 (file)
@@ -3334,12 +3334,8 @@ DEFINE_DEBUGFS_ATTRIBUTE(fault_around_bytes_fops,
 
 static int __init fault_around_debugfs(void)
 {
-       void *ret;
-
-       ret = debugfs_create_file_unsafe("fault_around_bytes", 0644, NULL, NULL,
-                       &fault_around_bytes_fops);
-       if (!ret)
-               pr_warn("Failed to create fault_around_bytes in debugfs");
+       debugfs_create_file_unsafe("fault_around_bytes", 0644, NULL, NULL,
+                                  &fault_around_bytes_fops);
        return 0;
 }
 late_initcall(fault_around_debugfs);
index 09bf2c5f8b4b938fefe726d1910580407fdd644d..9be9a22ebe3512bf6df4132fd65a67911c185a83 100644 (file)
@@ -3230,24 +3230,14 @@ static int __init fail_page_alloc_debugfs(void)
 
        dir = fault_create_debugfs_attr("fail_page_alloc", NULL,
                                        &fail_page_alloc.attr);
-       if (IS_ERR(dir))
-               return PTR_ERR(dir);
-
-       if (!debugfs_create_bool("ignore-gfp-wait", mode, dir,
-                               &fail_page_alloc.ignore_gfp_reclaim))
-               goto fail;
-       if (!debugfs_create_bool("ignore-gfp-highmem", mode, dir,
-                               &fail_page_alloc.ignore_gfp_highmem))
-               goto fail;
-       if (!debugfs_create_u32("min-order", mode, dir,
-                               &fail_page_alloc.min_order))
-               goto fail;
 
-       return 0;
-fail:
-       debugfs_remove_recursive(dir);
+       debugfs_create_bool("ignore-gfp-wait", mode, dir,
+                           &fail_page_alloc.ignore_gfp_reclaim);
+       debugfs_create_bool("ignore-gfp-highmem", mode, dir,
+                           &fail_page_alloc.ignore_gfp_highmem);
+       debugfs_create_u32("min-order", mode, dir, &fail_page_alloc.min_order);
 
-       return -ENOMEM;
+       return 0;
 }
 
 late_initcall(fail_page_alloc_debugfs);
index 28b06524939fa853307307469c76ac76d7955304..925b6f44a444afcddc2a634b8fafb3626eaeb16d 100644 (file)
@@ -625,16 +625,14 @@ static const struct file_operations proc_page_owner_operations = {
 
 static int __init pageowner_init(void)
 {
-       struct dentry *dentry;
-
        if (!static_branch_unlikely(&page_owner_inited)) {
                pr_info("page_owner is disabled\n");
                return 0;
        }
 
-       dentry = debugfs_create_file("page_owner", 0400, NULL,
-                                    NULL, &proc_page_owner_operations);
+       debugfs_create_file("page_owner", 0400, NULL, NULL,
+                           &proc_page_owner_operations);
 
-       return PTR_ERR_OR_ZERO(dentry);
+       return 0;
 }
 late_initcall(pageowner_init)
index 83b30edc2f7f39eeaf17cd6bbd2fbad863ce1503..36b56f858f0f0a8eb8db003d2b2a74a21a4c37f1 100644 (file)
@@ -2121,21 +2121,14 @@ static int __init extfrag_debug_init(void)
        struct dentry *extfrag_debug_root;
 
        extfrag_debug_root = debugfs_create_dir("extfrag", NULL);
-       if (!extfrag_debug_root)
-               return -ENOMEM;
 
-       if (!debugfs_create_file("unusable_index", 0444,
-                       extfrag_debug_root, NULL, &unusable_file_ops))
-               goto fail;
+       debugfs_create_file("unusable_index", 0444, extfrag_debug_root, NULL,
+                           &unusable_file_ops);
 
-       if (!debugfs_create_file("extfrag_index", 0444,
-                       extfrag_debug_root, NULL, &extfrag_file_ops))
-               goto fail;
+       debugfs_create_file("extfrag_index", 0444, extfrag_debug_root, NULL,
+                           &extfrag_file_ops);
 
        return 0;
-fail:
-       debugfs_remove_recursive(extfrag_debug_root);
-       return -ENOMEM;
 }
 
 module_init(extfrag_debug_init);