sysfs: Fix regression when adding a file to an existing group
authorTyler Hicks <tyhicks@canonical.com>
Fri, 27 Jul 2018 21:33:27 +0000 (21:33 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 29 Jul 2018 20:11:28 +0000 (13:11 -0700)
Commit 5f81880d5204 ("sysfs, kobject: allow creating kobject belonging
to arbitrary users") incorrectly changed the argument passed as the
parent parameter when calling sysfs_add_file_mode_ns(). This caused some
sysfs attribute files to not be added correctly to certain groups.

Fixes: 5f81880d5204 ("sysfs, kobject: allow creating kobject belonging to arbitrary users")
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Reported-by: Heiner Kallweit <hkallweit1@gmail.com>
Tested-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
fs/sysfs/file.c

index fa46216523cf4368a96463ae94e9203ade03bb24..052e5ad9a4d2122571389c1d3dc42e99dfda037e 100644 (file)
@@ -373,7 +373,7 @@ int sysfs_add_file_to_group(struct kobject *kobj,
                return -ENOENT;
 
        kobject_get_ownership(kobj, &uid, &gid);
-       error = sysfs_add_file_mode_ns(kobj->sd, attr, false,
+       error = sysfs_add_file_mode_ns(parent, attr, false,
                                       attr->mode, uid, gid, NULL);
        kernfs_put(parent);