Skip to content

Commit

Permalink
fail_function: no need to check return value of debugfs_create functions
Browse files Browse the repository at this point in the history
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.

Cc: Kees Cook <[email protected]>
Cc: Josef Bacik <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: "Naveen N. Rao" <[email protected]>
Cc: zhong jiang <[email protected]>
Acked-by: Masami Hiramatsu <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
gregkh committed Jun 3, 2019
1 parent 03eb2a0 commit 4aa3b1f
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions kernel/fail_function.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,13 @@ static int fei_retval_get(void *data, u64 *val)
DEFINE_DEBUGFS_ATTRIBUTE(fei_retval_ops, fei_retval_get, fei_retval_set,
"%llx\n");

static int fei_debugfs_add_attr(struct fei_attr *attr)
static void fei_debugfs_add_attr(struct fei_attr *attr)
{
struct dentry *dir;

dir = debugfs_create_dir(attr->kp.symbol_name, fei_debugfs_dir);
if (!dir)
return -ENOMEM;

if (!debugfs_create_file("retval", 0600, dir, attr, &fei_retval_ops)) {
debugfs_remove_recursive(dir);
return -ENOMEM;
}

return 0;
debugfs_create_file("retval", 0600, dir, attr, &fei_retval_ops);
}

static void fei_debugfs_remove_attr(struct fei_attr *attr)
Expand Down Expand Up @@ -306,7 +299,7 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,

ret = register_kprobe(&attr->kp);
if (!ret)
ret = fei_debugfs_add_attr(attr);
fei_debugfs_add_attr(attr);
if (ret < 0)
fei_attr_remove(attr);
else {
Expand Down Expand Up @@ -337,19 +330,13 @@ static int __init fei_debugfs_init(void)
return PTR_ERR(dir);

/* injectable attribute is just a symlink of error_inject/list */
if (!debugfs_create_symlink("injectable", dir,
"../error_injection/list"))
goto error;
debugfs_create_symlink("injectable", dir, "../error_injection/list");

if (!debugfs_create_file("inject", 0600, dir, NULL, &fei_ops))
goto error;
debugfs_create_file("inject", 0600, dir, NULL, &fei_ops);

fei_debugfs_dir = dir;

return 0;
error:
debugfs_remove_recursive(dir);
return -ENOMEM;
}

late_initcall(fei_debugfs_init);

0 comments on commit 4aa3b1f

Please sign in to comment.