diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2018-08-15 14:39:36 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2018-08-15 14:39:36 +1000 |
commit | c90f81a18f7c1c998f889e977902723a87fac7c9 (patch) | |
tree | 73547ad8a483df5decc51bfc1af04bb21ca8f886 /fs | |
parent | 50c1701d1c7b3d29dda53c6f050f23cb72c45063 (diff) | |
parent | d2fc88a61b4ea99f574bde16e92718e22f312136 (diff) | |
download | linux-next-c90f81a18f7c1c998f889e977902723a87fac7c9.tar.gz |
Merge remote-tracking branch 'driver-core/driver-core-next'
Diffstat (limited to 'fs')
-rw-r--r-- | fs/kernfs/symlink.c | 2 | ||||
-rw-r--r-- | fs/sysfs/group.c | 30 |
2 files changed, 23 insertions, 9 deletions
diff --git a/fs/kernfs/symlink.c b/fs/kernfs/symlink.c index 5ffed48f3d0e..305b220af45d 100644 --- a/fs/kernfs/symlink.c +++ b/fs/kernfs/symlink.c @@ -97,7 +97,7 @@ static int kernfs_get_target_path(struct kernfs_node *parent, int slen = strlen(kn->name); len -= slen; - strncpy(s + len, kn->name, slen); + memcpy(s + len, kn->name, slen); if (len) s[--len] = '/'; diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index c7a716c4acc9..1eb2d6307663 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c @@ -124,13 +124,22 @@ static int internal_create_group(struct kobject *kobj, int update, } kobject_get_ownership(kobj, &uid, &gid); if (grp->name) { - kn = kernfs_create_dir_ns(kobj->sd, grp->name, - S_IRWXU | S_IRUGO | S_IXUGO, - uid, gid, kobj, NULL); - if (IS_ERR(kn)) { - if (PTR_ERR(kn) == -EEXIST) - sysfs_warn_dup(kobj->sd, grp->name); - return PTR_ERR(kn); + if (update) { + kn = kernfs_find_and_get(kobj->sd, grp->name); + if (!kn) { + pr_warn("Can't update unknown attr grp name: %s/%s\n", + kobj->name, grp->name); + return -EINVAL; + } + } else { + kn = kernfs_create_dir_ns(kobj->sd, grp->name, + S_IRWXU | S_IRUGO | S_IXUGO, + uid, gid, kobj, NULL); + if (IS_ERR(kn)) { + if (PTR_ERR(kn) == -EEXIST) + sysfs_warn_dup(kobj->sd, grp->name); + return PTR_ERR(kn); + } } } else kn = kobj->sd; @@ -141,6 +150,10 @@ static int internal_create_group(struct kobject *kobj, int update, kernfs_remove(kn); } kernfs_put(kn); + + if (grp->name && update) + kernfs_put(kn); + return error; } @@ -205,7 +218,8 @@ EXPORT_SYMBOL_GPL(sysfs_create_groups); * of the attribute files being created already exist. Furthermore, * if the visibility of the files has changed through the is_visible() * callback, it will update the permissions and add or remove the - * relevant files. + * relevant files. Changing a group's name (subdirectory name under + * kobj's directory in sysfs) is not allowed. * * The primary use for this function is to call it after making a change * that affects group visibility. |