LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] kobject: kobject_add_internal cleanup
@ 2021-07-27 14:32 Qiao Yanbo
  2021-07-28 10:10 ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Qiao Yanbo @ 2021-07-27 14:32 UTC (permalink / raw)
  To: gregkh; +Cc: rafael, linux-kernel, qiaoyanbo

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



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

end of thread, other threads:[~2021-07-30 13:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27 14:32 [PATCH] kobject: kobject_add_internal cleanup Qiao Yanbo
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

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).