diff options
author | Tejun Heo <tj@kernel.org> | 2013-10-24 11:49:07 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-10-29 18:12:06 -0400 |
commit | 56b3f3b884652395e1025a8e4f1c4bd47bc112c4 (patch) | |
tree | 8253438bdcaddafb5ce406828bd8b9073f215a7b /fs/sysfs/file.c | |
parent | 6fffcfa7c0fc438d3667b4eb2074d94f69c12c7b (diff) |
sysfs: merge sysfs_elem_bin_attr into sysfs_elem_attr
3124eb1679 ("sysfs: merge regular and bin file handling") folded bin
file handling into regular file handling. Among other things, bin
file now shares the same open path including sysfs_open_dirent
association using sysfs_dirent->s_attr.open. This is buggy because
->s_bin_attr lives in the same union and doesn't have the field. This
bug doesn't trigger because sysfs_elem_bin_attr doesn't have an active
field at the conflicting position. It does have a field "buffers" but
it isn't used anymore.
This patch collapses sysfs_elem_bin_attr into sysfs_elem_attr so that
the bin_attr is accessed through ->s_attr.bin_attr which lives with
->s_attr.attr in an anonymous union. The code paths already assume
bin_attr contains attr as the first element, so this doesn't add any
more assumptions while making it explicit that the two types are
handled together.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/sysfs/file.c')
-rw-r--r-- | fs/sysfs/file.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index c3795978b404..0d7368d43619 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -154,7 +154,7 @@ static ssize_t sysfs_bin_read(struct file *file, char __user *userbuf, | |||
154 | size_t bytes, loff_t *off) | 154 | size_t bytes, loff_t *off) |
155 | { | 155 | { |
156 | struct sysfs_open_file *of = sysfs_of(file); | 156 | struct sysfs_open_file *of = sysfs_of(file); |
157 | struct bin_attribute *battr = of->sd->s_bin_attr.bin_attr; | 157 | struct bin_attribute *battr = of->sd->s_attr.bin_attr; |
158 | struct kobject *kobj = of->sd->s_parent->s_dir.kobj; | 158 | struct kobject *kobj = of->sd->s_parent->s_dir.kobj; |
159 | loff_t size = file_inode(file)->i_size; | 159 | loff_t size = file_inode(file)->i_size; |
160 | int count = min_t(size_t, bytes, PAGE_SIZE); | 160 | int count = min_t(size_t, bytes, PAGE_SIZE); |
@@ -236,7 +236,7 @@ static int flush_write_buffer(struct sysfs_open_file *of, char *buf, loff_t off, | |||
236 | } | 236 | } |
237 | 237 | ||
238 | if (sysfs_is_bin(of->sd)) { | 238 | if (sysfs_is_bin(of->sd)) { |
239 | struct bin_attribute *battr = of->sd->s_bin_attr.bin_attr; | 239 | struct bin_attribute *battr = of->sd->s_attr.bin_attr; |
240 | 240 | ||
241 | rc = -EIO; | 241 | rc = -EIO; |
242 | if (battr->write) | 242 | if (battr->write) |
@@ -466,7 +466,7 @@ static const struct vm_operations_struct sysfs_bin_vm_ops = { | |||
466 | static int sysfs_bin_mmap(struct file *file, struct vm_area_struct *vma) | 466 | static int sysfs_bin_mmap(struct file *file, struct vm_area_struct *vma) |
467 | { | 467 | { |
468 | struct sysfs_open_file *of = sysfs_of(file); | 468 | struct sysfs_open_file *of = sysfs_of(file); |
469 | struct bin_attribute *battr = of->sd->s_bin_attr.bin_attr; | 469 | struct bin_attribute *battr = of->sd->s_attr.bin_attr; |
470 | struct kobject *kobj = of->sd->s_parent->s_dir.kobj; | 470 | struct kobject *kobj = of->sd->s_parent->s_dir.kobj; |
471 | int rc; | 471 | int rc; |
472 | 472 | ||
@@ -618,7 +618,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file) | |||
618 | return -ENODEV; | 618 | return -ENODEV; |
619 | 619 | ||
620 | if (sysfs_is_bin(attr_sd)) { | 620 | if (sysfs_is_bin(attr_sd)) { |
621 | struct bin_attribute *battr = attr_sd->s_bin_attr.bin_attr; | 621 | struct bin_attribute *battr = attr_sd->s_attr.bin_attr; |
622 | 622 | ||
623 | has_read = battr->read || battr->mmap; | 623 | has_read = battr->read || battr->mmap; |
624 | has_write = battr->write || battr->mmap; | 624 | has_write = battr->write || battr->mmap; |