]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
kobject: Improve doc clarity kobject_init_and_add()
authorTobin C. Harding <tobin@kernel.org>
Sat, 27 Apr 2019 23:56:52 +0000 (09:56 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 28 Apr 2019 16:16:03 +0000 (18:16 +0200)
Function kobject_init_and_add() is currently misused in a number of
places in the kernel.  On error return kobject_put() must be called but
is at times not.

Make the function documentation more explicit about calling
kobject_put() in the error path.

Signed-off-by: Tobin C. Harding <tobin@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
lib/kobject.c

index c97b5729f94d886014f34013dca36b9bfb47341d..a30ee046794247a784ef9adb6ea1e9e0dd335c60 100644 (file)
@@ -450,9 +450,12 @@ EXPORT_SYMBOL(kobject_add);
  * @parent: pointer to the parent of this kobject.
  * @fmt: the name of the kobject.
  *
- * This function combines the call to kobject_init() and
- * kobject_add().  The same type of error handling after a call to
- * kobject_add() and kobject lifetime rules are the same here.
+ * This function combines the call to kobject_init() and kobject_add().
+ *
+ * If this function returns an error, kobject_put() must be called to
+ * properly clean up the memory associated with the object.  This is the
+ * same type of error handling after a call to kobject_add() and kobject
+ * lifetime rules are the same here.
  */
 int kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype,
                         struct kobject *parent, const char *fmt, ...)