The setup code in batadv_socket_setup() and debug_log_setup() wrongly assumes that debugfs_create_file() returns !0 on error. Since it actually returns a pointer on success[1], the following check should be inverted.
Also, use the return value from the two setup functions in batadv_debugfs_add_meshif().
[1] http://www.fsl.cs.sunysb.edu/kernel-api/re464.html
Signed-off-by: Martin Hundebøll martin@hundeboll.net --- bat_debugfs.c | 11 +++++++---- icmp_socket.c | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/bat_debugfs.c b/bat_debugfs.c index cd636db..bd9325d 100644 --- a/bat_debugfs.c +++ b/bat_debugfs.c @@ -193,13 +193,13 @@ static int debug_log_setup(struct bat_priv *bat_priv)
d = debugfs_create_file("log", S_IFREG | S_IRUSR, bat_priv->debug_dir, bat_priv, &log_fops); - if (d) + if (!d) goto err;
return 0;
err: - return 1; + return -ENOMEM; }
static void debug_log_cleanup(struct bat_priv *bat_priv) @@ -347,8 +347,11 @@ int batadv_debugfs_add_meshif(struct net_device *dev) if (!bat_priv->debug_dir) goto out;
- batadv_socket_setup(bat_priv); - debug_log_setup(bat_priv); + if (batadv_socket_setup(bat_priv)) + goto rem_attr; + + if (debug_log_setup(bat_priv)) + goto rem_attr;
for (bat_debug = mesh_debuginfos; *bat_debug; ++bat_debug) { file = debugfs_create_file(((*bat_debug)->attr).name, diff --git a/icmp_socket.c b/icmp_socket.c index 3fad5aa..40c5e18 100644 --- a/icmp_socket.c +++ b/icmp_socket.c @@ -283,13 +283,13 @@ int batadv_socket_setup(struct bat_priv *bat_priv)
d = debugfs_create_file(ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR, bat_priv->debug_dir, bat_priv, &fops); - if (d) + if (!d) goto err;
return 0;
err: - return 1; + return -ENOMEM; }
static void bat_socket_add_packet(struct socket_client *socket_client,
From: Martin Hundebøll martin@hundeboll.net
The setup code in batadv_socket_setup() and debug_log_setup() wrongly assumes that debugfs_create_file() returns !0 on error. Since it actually returns a pointer on success[1], the following check should be inverted.
Also, use the return value from the two setup functions in batadv_debugfs_add_meshif().
[1] http://www.fsl.cs.sunysb.edu/kernel-api/re464.html
Signed-off-by: Martin Hundebøll martin@hundeboll.net [sven@narfation.org: Fix conflicts with namespace patches] Signed-off-by: Sven Eckelmann sven@narfation.org --- debugfs.c | 11 +++++++---- icmp_socket.c | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/debugfs.c b/debugfs.c index de610ba..e45cf0e 100644 --- a/debugfs.c +++ b/debugfs.c @@ -206,13 +206,13 @@ static int batadv_debug_log_setup(struct batadv_priv *bat_priv) d = debugfs_create_file("log", S_IFREG | S_IRUSR, bat_priv->debug_dir, bat_priv, &batadv_log_fops); - if (d) + if (!d) goto err;
return 0;
err: - return 1; + return -ENOMEM; }
static void batadv_debug_log_cleanup(struct batadv_priv *bat_priv) @@ -362,8 +362,11 @@ int batadv_debugfs_add_meshif(struct net_device *dev) if (!bat_priv->debug_dir) goto out;
- batadv_socket_setup(bat_priv); - batadv_debug_log_setup(bat_priv); + if (batadv_socket_setup(bat_priv) < 0) + goto rem_attr; + + if (batadv_debug_log_setup(bat_priv) < 0) + goto rem_attr;
for (bat_debug = batadv_mesh_debuginfos; *bat_debug; ++bat_debug) { file = debugfs_create_file(((*bat_debug)->attr).name, diff --git a/icmp_socket.c b/icmp_socket.c index d370061..bde3cf7 100644 --- a/icmp_socket.c +++ b/icmp_socket.c @@ -284,13 +284,13 @@ int batadv_socket_setup(struct batadv_priv *bat_priv)
d = debugfs_create_file(BATADV_ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR, bat_priv->debug_dir, bat_priv, &batadv_fops); - if (d) + if (!d) goto err;
return 0;
err: - return 1; + return -ENOMEM; }
static void batadv_socket_add_packet(struct batadv_socket_client *socket_client,
On Tuesday, June 12, 2012 15:25:03 Sven Eckelmann wrote:
From: Martin Hundebøll martin@hundeboll.net
The setup code in batadv_socket_setup() and debug_log_setup() wrongly assumes that debugfs_create_file() returns !0 on error. Since it actually returns a pointer on success[1], the following check should be inverted.
Also, use the return value from the two setup functions in batadv_debugfs_add_meshif().
[1] http://www.fsl.cs.sunysb.edu/kernel-api/re464.html
Signed-off-by: Martin Hundebøll martin@hundeboll.net [sven@narfation.org: Fix conflicts with namespace patches] Signed-off-by: Sven Eckelmann sven@narfation.org
debugfs.c | 11 +++++++---- icmp_socket.c | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-)
Applied in revision 86b9780.
Thanks, Marek
b.a.t.m.a.n@lists.open-mesh.org