summaryrefslogtreecommitdiffstats
path: root/lib/kobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kobject.c')
-rw-r--r--lib/kobject.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index aa89edcd2b63..ede40005db28 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -82,6 +82,7 @@ static int populate_dir(struct kobject *kobj)
82 82
83static int create_dir(struct kobject *kobj) 83static int create_dir(struct kobject *kobj)
84{ 84{
85 const struct kobj_type *ktype = get_ktype(kobj);
85 const struct kobj_ns_type_operations *ops; 86 const struct kobj_ns_type_operations *ops;
86 int error; 87 int error;
87 88
@@ -95,6 +96,14 @@ static int create_dir(struct kobject *kobj)
95 return error; 96 return error;
96 } 97 }
97 98
99 if (ktype) {
100 error = sysfs_create_groups(kobj, ktype->default_groups);
101 if (error) {
102 sysfs_remove_dir(kobj);
103 return error;
104 }
105 }
106
98 /* 107 /*
99 * @kobj->sd may be deleted by an ancestor going away. Hold an 108 * @kobj->sd may be deleted by an ancestor going away. Hold an
100 * extra reference so that it stays until @kobj is gone. 109 * extra reference so that it stays until @kobj is gone.
@@ -584,11 +593,16 @@ EXPORT_SYMBOL_GPL(kobject_move);
584void kobject_del(struct kobject *kobj) 593void kobject_del(struct kobject *kobj)
585{ 594{
586 struct kernfs_node *sd; 595 struct kernfs_node *sd;
596 const struct kobj_type *ktype = get_ktype(kobj);
587 597
588 if (!kobj) 598 if (!kobj)
589 return; 599 return;
590 600
591 sd = kobj->sd; 601 sd = kobj->sd;
602
603 if (ktype)
604 sysfs_remove_groups(kobj, ktype->default_groups);
605
592 sysfs_remove_dir(kobj); 606 sysfs_remove_dir(kobj);
593 sysfs_put(sd); 607 sysfs_put(sd);
594 608