diff options
-rw-r--r-- | fs/sysfs/file.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index 335288b9be0f..4013d7905e84 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -437,8 +437,8 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode) | |||
437 | { | 437 | { |
438 | struct dentry *dir = kobj->dentry; | 438 | struct dentry *dir = kobj->dentry; |
439 | struct dentry *victim; | 439 | struct dentry *victim; |
440 | struct sysfs_dirent *sd; | 440 | struct inode * inode; |
441 | umode_t umode = (mode & S_IALLUGO) | S_IFREG; | 441 | struct iattr newattrs; |
442 | int res = -ENOENT; | 442 | int res = -ENOENT; |
443 | 443 | ||
444 | down(&dir->d_inode->i_sem); | 444 | down(&dir->d_inode->i_sem); |
@@ -446,13 +446,15 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode) | |||
446 | if (!IS_ERR(victim)) { | 446 | if (!IS_ERR(victim)) { |
447 | if (victim->d_inode && | 447 | if (victim->d_inode && |
448 | (victim->d_parent->d_inode == dir->d_inode)) { | 448 | (victim->d_parent->d_inode == dir->d_inode)) { |
449 | sd = victim->d_fsdata; | 449 | inode = victim->d_inode; |
450 | attr->mode = mode; | 450 | down(&inode->i_sem); |
451 | sd->s_mode = umode; | 451 | newattrs.ia_mode = (mode & S_IALLUGO) | |
452 | victim->d_inode->i_mode = umode; | 452 | (inode->i_mode & ~S_IALLUGO); |
453 | dput(victim); | 453 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; |
454 | res = 0; | 454 | res = notify_change(victim, &newattrs); |
455 | up(&inode->i_sem); | ||
455 | } | 456 | } |
457 | dput(victim); | ||
456 | } | 458 | } |
457 | up(&dir->d_inode->i_sem); | 459 | up(&dir->d_inode->i_sem); |
458 | 460 | ||