All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kobject: Improve doc clarity kobject_init_and_add()
@ 2019-04-27 23:56 Tobin C. Harding
  2019-04-29  7:00 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Tobin C. Harding @ 2019-04-27 23:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki; +Cc: Tobin C. Harding, linux-kernel

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>
---
 lib/kobject.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/kobject.c b/lib/kobject.c
index aa89edcd2b63..58d1d7a64203 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -437,9 +437,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, ...)
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] kobject: Improve doc clarity kobject_init_and_add()
  2019-04-27 23:56 [PATCH] kobject: Improve doc clarity kobject_init_and_add() Tobin C. Harding
@ 2019-04-29  7:00 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2019-04-29  7:00 UTC (permalink / raw)
  To: Tobin C. Harding
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Linux Kernel Mailing List

On Sun, Apr 28, 2019 at 1:57 AM Tobin C. Harding <tobin@kernel.org> wrote:
>
> 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>

Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  lib/kobject.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/lib/kobject.c b/lib/kobject.c
> index aa89edcd2b63..58d1d7a64203 100644
> --- a/lib/kobject.c
> +++ b/lib/kobject.c
> @@ -437,9 +437,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, ...)
> --
> 2.21.0
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-29  7:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-27 23:56 [PATCH] kobject: Improve doc clarity kobject_init_and_add() Tobin C. Harding
2019-04-29  7:00 ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.