Skip to content

Commit

Permalink
l2tp: 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.

Also, there is no need to store the individual debugfs file name, just
remove the whole directory all at once, saving a local variable.

Cc: "David S. Miller" <[email protected]>
Cc: Guillaume Nault <[email protected]>
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Acked-by: Guillaume Nault <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
gregkh authored and davem330 committed Jun 14, 2019
1 parent 0b55b63 commit 3adcfa4
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions net/l2tp/l2tp_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "l2tp_core.h"

static struct dentry *rootdir;
static struct dentry *tunnels;

struct l2tp_dfs_seq_data {
struct net *net;
Expand Down Expand Up @@ -326,32 +325,18 @@ static const struct file_operations l2tp_dfs_fops = {

static int __init l2tp_debugfs_init(void)
{
int rc = 0;

rootdir = debugfs_create_dir("l2tp", NULL);
if (IS_ERR(rootdir)) {
rc = PTR_ERR(rootdir);
rootdir = NULL;
goto out;
}

tunnels = debugfs_create_file("tunnels", 0600, rootdir, NULL, &l2tp_dfs_fops);
if (tunnels == NULL)
rc = -EIO;
debugfs_create_file("tunnels", 0600, rootdir, NULL, &l2tp_dfs_fops);

pr_info("L2TP debugfs support\n");

out:
if (rc)
pr_warn("unable to init\n");

return rc;
return 0;
}

static void __exit l2tp_debugfs_exit(void)
{
debugfs_remove(tunnels);
debugfs_remove(rootdir);
debugfs_remove_recursive(rootdir);
}

module_init(l2tp_debugfs_init);
Expand Down

0 comments on commit 3adcfa4

Please sign in to comment.