[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210727143212.39142-1-qiaoyanbo_310@163.com>
Date: Tue, 27 Jul 2021 22:32:12 +0800
From: Qiao Yanbo <qiaoyanbo_310@....com>
To: gregkh@...uxfoundation.org
Cc: rafael@...nel.org, linux-kernel@...r.kernel.org,
qiaoyanbo <qiaoyanbo_310@....com>
Subject: [PATCH] kobject: kobject_add_internal cleanup
From: qiaoyanbo <qiaoyanbo_310@....com>
parent assignment in "if" block only need to consider when parent is NULL.
Signed-off-by: qiaoyanbo <qiaoyanbo_310@....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
Powered by blists - more mailing lists