aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/sysfs/file.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 4045bdcc4b33..b834f1709f9f 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -568,7 +568,11 @@ int sysfs_add_file_to_group(struct kobject *kobj,
568 struct sysfs_dirent *dir_sd; 568 struct sysfs_dirent *dir_sd;
569 int error; 569 int error;
570 570
571 dir_sd = sysfs_get_dirent(kobj->sd, group); 571 if (group)
572 dir_sd = sysfs_get_dirent(kobj->sd, group);
573 else
574 dir_sd = sysfs_get(kobj->sd);
575
572 if (!dir_sd) 576 if (!dir_sd)
573 return -ENOENT; 577 return -ENOENT;
574 578
@@ -656,7 +660,10 @@ void sysfs_remove_file_from_group(struct kobject *kobj,
656{ 660{
657 struct sysfs_dirent *dir_sd; 661 struct sysfs_dirent *dir_sd;
658 662
659 dir_sd = sysfs_get_dirent(kobj->sd, group); 663 if (group)
664 dir_sd = sysfs_get_dirent(kobj->sd, group);
665 else
666 dir_sd = sysfs_get(kobj->sd);
660 if (dir_sd) { 667 if (dir_sd) {
661 sysfs_hash_and_remove(dir_sd, attr->name); 668 sysfs_hash_and_remove(dir_sd, attr->name);
662 sysfs_put(dir_sd); 669 sysfs_put(dir_sd);