summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobin C. Harding <tobin@kernel.org>2019-04-27 19:56:52 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-04-28 12:16:03 -0400
commit1fd7c3b438a2e4741435ed4d45546c03abf045b2 (patch)
tree8e15a4600d61565b3495fe0040d49f3019371881
parent92067f843854be0eef1e41ff00cb465247a83c42 (diff)
kobject: Improve doc clarity kobject_init_and_add()
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>
-rw-r--r--lib/kobject.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index c97b5729f94d..a30ee0467942 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -450,9 +450,12 @@ EXPORT_SYMBOL(kobject_add);
450 * @parent: pointer to the parent of this kobject. 450 * @parent: pointer to the parent of this kobject.
451 * @fmt: the name of the kobject. 451 * @fmt: the name of the kobject.
452 * 452 *
453 * This function combines the call to kobject_init() and 453 * This function combines the call to kobject_init() and kobject_add().
454 * kobject_add(). The same type of error handling after a call to 454 *
455 * kobject_add() and kobject lifetime rules are the same here. 455 * If this function returns an error, kobject_put() must be called to
456 * properly clean up the memory associated with the object. This is the
457 * same type of error handling after a call to kobject_add() and kobject
458 * lifetime rules are the same here.
456 */ 459 */
457int kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype, 460int kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype,
458 struct kobject *parent, const char *fmt, ...) 461 struct kobject *parent, const char *fmt, ...)