nfsd: nfsd should drop CAP_MKNOD for non-root
[safe/jmp/linux-2.6] / lib / kobject_uevent.c
index 5b6d7f6..318328d 100644 (file)
  */
 
 #include <linux/spinlock.h>
+#include <linux/string.h>
+#include <linux/kobject.h>
+#include <linux/module.h>
+
 #include <linux/socket.h>
 #include <linux/skbuff.h>
 #include <linux/netlink.h>
-#include <linux/string.h>
-#include <linux/kobject.h>
 #include <net/sock.h>
 
 
@@ -99,7 +101,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
        int retval = 0;
 
        pr_debug("kobject: '%s' (%p): %s\n",
-                kobject_name(kobj), kobj, __FUNCTION__);
+                kobject_name(kobj), kobj, __func__);
 
        /* search the kset we belong to */
        top_kobj = kobj;
@@ -109,7 +111,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
        if (!top_kobj->kset) {
                pr_debug("kobject: '%s' (%p): %s: attempted to send uevent "
                         "without kset!\n", kobject_name(kobj), kobj,
-                        __FUNCTION__);
+                        __func__);
                return -EINVAL;
        }
 
@@ -121,7 +123,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
                if (!uevent_ops->filter(kset, kobj)) {
                        pr_debug("kobject: '%s' (%p): %s: filter function "
                                 "caused the event to drop!\n",
-                                kobject_name(kobj), kobj, __FUNCTION__);
+                                kobject_name(kobj), kobj, __func__);
                        return 0;
                }
 
@@ -133,7 +135,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
        if (!subsystem) {
                pr_debug("kobject: '%s' (%p): %s: unset subsystem caused the "
                         "event to drop!\n", kobject_name(kobj), kobj,
-                        __FUNCTION__);
+                        __func__);
                return 0;
        }
 
@@ -163,7 +165,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
        /* keys passed in from the caller */
        if (envp_ext) {
                for (i = 0; envp_ext[i]; i++) {
-                       retval = add_uevent_var(env, envp_ext[i]);
+                       retval = add_uevent_var(env, "%s", envp_ext[i]);
                        if (retval)
                                goto exit;
                }
@@ -175,7 +177,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
                if (retval) {
                        pr_debug("kobject: '%s' (%p): %s: uevent() returned "
                                 "%d\n", kobject_name(kobj), kobj,
-                                __FUNCTION__, retval);
+                                __func__, retval);
                        goto exit;
                }
        }
@@ -223,8 +225,10 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
                        }
 
                        NETLINK_CB(skb).dst_group = 1;
-                       netlink_broadcast(uevent_sock, skb, 0, 1, GFP_KERNEL);
-               }
+                       retval = netlink_broadcast(uevent_sock, skb, 0, 1,
+                                                  GFP_KERNEL);
+               } else
+                       retval = -ENOMEM;
        }
 #endif
 
@@ -243,7 +247,8 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
                if (retval)
                        goto exit;
 
-               call_usermodehelper(argv[0], argv, env->envp, UMH_WAIT_EXEC);
+               retval = call_usermodehelper(argv[0], argv,
+                                            env->envp, UMH_WAIT_EXEC);
        }
 
 exit:
@@ -282,8 +287,7 @@ int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...)
        int len;
 
        if (env->envp_idx >= ARRAY_SIZE(env->envp)) {
-               printk(KERN_ERR "add_uevent_var: too many keys\n");
-               WARN_ON(1);
+               WARN(1, KERN_ERR "add_uevent_var: too many keys\n");
                return -ENOMEM;
        }
 
@@ -294,8 +298,7 @@ int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...)
        va_end(args);
 
        if (len >= (sizeof(env->buf) - env->buflen)) {
-               printk(KERN_ERR "add_uevent_var: buffer size too small\n");
-               WARN_ON(1);
+               WARN(1, KERN_ERR "add_uevent_var: buffer size too small\n");
                return -ENOMEM;
        }