The following commit has been merged in the master branch: commit 86b9780b49f721e248ce8a9a8da99e317ef08baf Author: Martin Hundebøll martin@hundeboll.net Date: Tue Jun 12 09:25:03 2012 +0200
batman-adv: Correctly check return value from debugfs_create_dir
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
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,