Skip to content

Commit e6764aa

Browse files
committed
Revert "kobject: Make sure the parent does not get released before its children"
This reverts commit 4ef12f7. Guenter reports: All my arm64be (arm64 big endian) boot tests crash with this patch applied. Reverting it fixes the problem. Crash log and bisect results (from pending-fixes branch) below. And also: arm64 images don't crash but report lots of "poison overwritten" backtraces like the one below. On arm, I see "refcount_t: underflow", also attached. I didn't bisect those, but given the context I would suspect the same culprit. Reported-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: Naresh Kamboju <[email protected]> Cc: kernel test robot <[email protected]> Cc: "Rafael J. Wysocki" <[email protected]> Cc: Heikki Krogerus <[email protected]> Cc: Brendan Higgins <[email protected]> Cc: Randy Dunlap <[email protected]> Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4ef12f7 commit e6764aa

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

lib/kobject.c

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,14 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent)
599599
}
600600
EXPORT_SYMBOL_GPL(kobject_move);
601601

602-
static void __kobject_del(struct kobject *kobj)
602+
/**
603+
* kobject_del() - Unlink kobject from hierarchy.
604+
* @kobj: object.
605+
*
606+
* This is the function that should be called to delete an object
607+
* successfully added via kobject_add().
608+
*/
609+
void kobject_del(struct kobject *kobj)
603610
{
604611
struct kernfs_node *sd;
605612
const struct kobj_type *ktype;
@@ -618,23 +625,9 @@ static void __kobject_del(struct kobject *kobj)
618625

619626
kobj->state_in_sysfs = 0;
620627
kobj_kset_leave(kobj);
628+
kobject_put(kobj->parent);
621629
kobj->parent = NULL;
622630
}
623-
624-
/**
625-
* kobject_del() - Unlink kobject from hierarchy.
626-
* @kobj: object.
627-
*
628-
* This is the function that should be called to delete an object
629-
* successfully added via kobject_add().
630-
*/
631-
void kobject_del(struct kobject *kobj)
632-
{
633-
struct kobject *parent = kobj->parent;
634-
635-
__kobject_del(kobj);
636-
kobject_put(parent);
637-
}
638631
EXPORT_SYMBOL(kobject_del);
639632

640633
/**
@@ -670,7 +663,6 @@ EXPORT_SYMBOL(kobject_get_unless_zero);
670663
*/
671664
static void kobject_cleanup(struct kobject *kobj)
672665
{
673-
struct kobject *parent = kobj->parent;
674666
struct kobj_type *t = get_ktype(kobj);
675667
const char *name = kobj->name;
676668

@@ -692,7 +684,7 @@ static void kobject_cleanup(struct kobject *kobj)
692684
if (kobj->state_in_sysfs) {
693685
pr_debug("kobject: '%s' (%p): auto cleanup kobject_del\n",
694686
kobject_name(kobj), kobj);
695-
__kobject_del(kobj);
687+
kobject_del(kobj);
696688
}
697689

698690
if (t && t->release) {
@@ -706,8 +698,6 @@ static void kobject_cleanup(struct kobject *kobj)
706698
pr_debug("kobject: '%s': free name\n", name);
707699
kfree_const(name);
708700
}
709-
710-
kobject_put(parent);
711701
}
712702

713703
#ifdef CONFIG_DEBUG_KOBJECT_RELEASE

0 commit comments

Comments
 (0)