linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qiao Yanbo <qiaoyanbo_310@163.com>
To: gregkh@linuxfoundation.org
Cc: rafael@kernel.org, linux-kernel@vger.kernel.org,
	qiaoyanbo <qiaoyanbo_310@163.com>
Subject: [PATCH] kobject: kobject_add_internal cleanup
Date: Tue, 27 Jul 2021 22:32:12 +0800	[thread overview]
Message-ID: <20210727143212.39142-1-qiaoyanbo_310@163.com> (raw)

From: qiaoyanbo <qiaoyanbo_310@163.com>

parent assignment in "if" block only need to consider when parent is NULL.

Signed-off-by: qiaoyanbo <qiaoyanbo_310@163.com>
---
 lib/kobject.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/kobject.c b/lib/kobject.c
index ea53b30cf..d1f4b3411 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -241,10 +241,11 @@ static int kobject_add_internal(struct kobject *kobj)
 
 	/* join kset if set, use it as parent if we do not already have one */
 	if (kobj->kset) {
-		if (!parent)
+		if (!parent) {
 			parent = kobject_get(&kobj->kset->kobj);
+			kobj->parent = parent;
+		}
 		kobj_kset_join(kobj);
-		kobj->parent = parent;
 	}
 
 	pr_debug("kobject: '%s' (%p): %s: parent: '%s', set: '%s'\n",
-- 
2.30.2



             reply	other threads:[~2021-07-27 14:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-27 14:32 Qiao Yanbo [this message]
2021-07-28 10:10 ` Greg KH
     [not found]   ` <3be7ce57.62f6.17af280a47f.Coremail.qiaoyanbo_310@163.com>
2021-07-29 13:59     ` Greg KH
     [not found]       ` <54cc7e43.808a.17af32725d9.Coremail.qiaoyanbo_310@163.com>
2021-07-30  4:48         ` Greg KH
2021-07-30 12:47           ` qiaoyanbo_310
2021-07-30 13:37             ` Greg KH

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=20210727143212.39142-1-qiaoyanbo_310@163.com \
    --to=qiaoyanbo_310@163.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --subject='Re: [PATCH] kobject: kobject_add_internal cleanup' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).