Commit 4169680e authored by YueHaibing's avatar YueHaibing Committed by Linus Torvalds

kernel/panic.c: taint: fix debugfs_simple_attr.cocci warnings

Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE for
debugfs files.

Semantic patch information:
Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file()
imposes some significant overhead as compared to
DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe().

Generated by: scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci

The _unsafe() part suggests that some of them "safeness
responsibilities" are now panic.c responsibilities.  The patch is OK
since panic's clear_warn_once_fops struct file_operations is safe
against removal, so we don't have to use otherwise necessary
debugfs_file_get()/debugfs_file_put().

[sergey.senozhatsky.work@gmail.com: changelog addition]
Link: http://lkml.kernel.org/r/1545990861-158097-1-git-send-email-yuehaibing@huawei.comSigned-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
Reviewed-by: default avatarSergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Petr Mladek <pmladek@suse.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c461aed3
...@@ -642,16 +642,14 @@ static int clear_warn_once_set(void *data, u64 val) ...@@ -642,16 +642,14 @@ static int clear_warn_once_set(void *data, u64 val)
return 0; return 0;
} }
DEFINE_SIMPLE_ATTRIBUTE(clear_warn_once_fops, DEFINE_DEBUGFS_ATTRIBUTE(clear_warn_once_fops, NULL, clear_warn_once_set,
NULL,
clear_warn_once_set,
"%lld\n"); "%lld\n");
static __init int register_warn_debugfs(void) static __init int register_warn_debugfs(void)
{ {
/* Don't care about failure */ /* Don't care about failure */
debugfs_create_file("clear_warn_once", 0200, NULL, debugfs_create_file_unsafe("clear_warn_once", 0200, NULL, NULL,
NULL, &clear_warn_once_fops); &clear_warn_once_fops);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment