Skip to content

Commit

Permalink
kobject: Improve doc clarity kobject_init_and_add()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Tobin C. Harding authored and gregkh committed Apr 28, 2019
1 parent 92067f8 commit 1fd7c3b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/kobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...)
Expand Down

0 comments on commit 1fd7c3b

Please sign in to comment.