public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Tobin C. Harding" <me@tobin.cc>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	cl@linux.com, tycho@tycho.ws, willy@infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] kobject: clean up the kobject add documentation a bit more
Date: Thu, 2 May 2019 12:22:24 +0200	[thread overview]
Message-ID: <20190502102224.GA15012@kroah.com> (raw)
In-Reply-To: <20190502081918.GA18363@eros.localdomain>

Commit 1fd7c3b438a2 ("kobject: Improve doc clarity kobject_init_and_add()")
tried to provide more clarity, but the reference to kobject_del() was
incorrect.  Fix that up by removing that line, and hopefully be more explicit
as to exactly what needs to happen here once you register a kobject with the
kobject core.

Cc: Tobin C. Harding <tobin@kernel.org>
Fixes: 1fd7c3b438a2 ("kobject: Improve doc clarity kobject_init_and_add()")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

diff --git a/lib/kobject.c b/lib/kobject.c
index 3f4b7e95b0c2..f2ccdbac8ed9 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -416,8 +416,12 @@ static __printf(3, 0) int kobject_add_varg(struct kobject *kobj,
  *         to this function be directly freed with a call to kfree(),
  *         that can leak memory.
  *
- *         If this call returns successfully and you later need to unwind
- *         kobject_add() for the error path you should call kobject_del().
+ *         If this function returns success, kobject_put() must also be called
+ *         in order to properly clean up the memory associated with the object.
+ *
+ *         In short, once this function is called, kobject_put() MUST be called
+ *         when the use of the object is finished in order to properly free
+ *         everything.
  */
 int kobject_add(struct kobject *kobj, struct kobject *parent,
 		const char *fmt, ...)

  reply	other threads:[~2019-05-02 10:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-27  8:13 memleak around kobject_init_and_add() Tobin C. Harding
2019-04-27 19:28 ` Greg Kroah-Hartman
2019-04-27 23:33   ` Tobin C. Harding
2019-04-28  1:19   ` Tobin C. Harding
2019-04-28 16:14     ` Greg Kroah-Hartman
2019-04-28 22:46       ` Tobin C. Harding
2019-05-01 21:56   ` Tobin C. Harding
2019-05-02  7:17     ` Greg Kroah-Hartman
2019-05-02  7:28       ` Greg Kroah-Hartman
2019-05-02  8:19         ` Tobin C. Harding
2019-05-02 10:22           ` Greg Kroah-Hartman [this message]
2019-05-03  1:25             ` [PATCH] kobject: clean up the kobject add documentation a bit more Tobin C. Harding
2019-05-03  6:27               ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190502102224.GA15012@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=cl@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@tobin.cc \
    --cc=rafael@kernel.org \
    --cc=tycho@tycho.ws \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox