diff options
Diffstat (limited to 'fs/sysfs')
-rw-r--r-- | fs/sysfs/file.c | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index faa1a803caa9..dc30d9e31683 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -579,38 +579,23 @@ EXPORT_SYMBOL_GPL(sysfs_add_file_to_group); | |||
579 | */ | 579 | */ |
580 | int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode) | 580 | int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode) |
581 | { | 581 | { |
582 | struct sysfs_dirent *victim_sd = NULL; | 582 | struct sysfs_dirent *sd; |
583 | struct dentry *victim = NULL; | ||
584 | struct inode * inode; | ||
585 | struct iattr newattrs; | 583 | struct iattr newattrs; |
586 | int rc; | 584 | int rc; |
587 | 585 | ||
588 | rc = -ENOENT; | 586 | mutex_lock(&sysfs_mutex); |
589 | victim_sd = sysfs_get_dirent(kobj->sd, attr->name); | ||
590 | if (!victim_sd) | ||
591 | goto out; | ||
592 | 587 | ||
593 | mutex_lock(&sysfs_rename_mutex); | 588 | rc = -ENOENT; |
594 | victim = sysfs_get_dentry(victim_sd); | 589 | sd = sysfs_find_dirent(kobj->sd, attr->name); |
595 | mutex_unlock(&sysfs_rename_mutex); | 590 | if (!sd) |
596 | if (IS_ERR(victim)) { | ||
597 | rc = PTR_ERR(victim); | ||
598 | victim = NULL; | ||
599 | goto out; | 591 | goto out; |
600 | } | ||
601 | |||
602 | inode = victim->d_inode; | ||
603 | 592 | ||
604 | mutex_lock(&inode->i_mutex); | 593 | newattrs.ia_mode = (mode & S_IALLUGO) | (sd->s_mode & ~S_IALLUGO); |
605 | |||
606 | newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); | ||
607 | newattrs.ia_valid = ATTR_MODE; | 594 | newattrs.ia_valid = ATTR_MODE; |
608 | rc = sysfs_setattr(victim, &newattrs); | 595 | rc = sysfs_sd_setattr(sd, &newattrs); |
609 | 596 | ||
610 | mutex_unlock(&inode->i_mutex); | ||
611 | out: | 597 | out: |
612 | dput(victim); | 598 | mutex_unlock(&sysfs_mutex); |
613 | sysfs_put(victim_sd); | ||
614 | return rc; | 599 | return rc; |
615 | } | 600 | } |
616 | EXPORT_SYMBOL_GPL(sysfs_chmod_file); | 601 | EXPORT_SYMBOL_GPL(sysfs_chmod_file); |