* [B.A.T.M.A.N.] [PATCH] batman-adv: Correctly check return value from debugfs_create_dir
@ 2012-05-15 22:06 Martin Hundebøll
2012-06-12 7:25 ` [B.A.T.M.A.N.] [PATCHv2] " Sven Eckelmann
0 siblings, 1 reply; 3+ messages in thread
From: Martin Hundebøll @ 2012-05-15 22:06 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Martin Hundebøll
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,
--
1.7.10.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [B.A.T.M.A.N.] [PATCHv2] batman-adv: Correctly check return value from debugfs_create_dir
2012-05-15 22:06 [B.A.T.M.A.N.] [PATCH] batman-adv: Correctly check return value from debugfs_create_dir Martin Hundebøll
@ 2012-06-12 7:25 ` Sven Eckelmann
2012-06-12 11:41 ` Marek Lindner
0 siblings, 1 reply; 3+ messages in thread
From: Sven Eckelmann @ 2012-06-12 7:25 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Martin Hundebøll
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,
--
1.7.10
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCHv2] batman-adv: Correctly check return value from debugfs_create_dir
2012-06-12 7:25 ` [B.A.T.M.A.N.] [PATCHv2] " Sven Eckelmann
@ 2012-06-12 11:41 ` Marek Lindner
0 siblings, 0 replies; 3+ messages in thread
From: Marek Lindner @ 2012-06-12 11:41 UTC (permalink / raw)
To: The list for a Better Approach To Mobile Ad-hoc Networking
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-06-12 11:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-15 22:06 [B.A.T.M.A.N.] [PATCH] batman-adv: Correctly check return value from debugfs_create_dir Martin Hundebøll
2012-06-12 7:25 ` [B.A.T.M.A.N.] [PATCHv2] " Sven Eckelmann
2012-06-12 11:41 ` Marek Lindner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox