]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - fs/sysfs/group.c
Merge remote-tracking branch 'chrome-platform/for-next'
[karo-tx-linux.git] / fs / sysfs / group.c
index e1236594fffec8d50b79eada956fdaadba663aff..dc1358b5ec95814c4e0f0ca0bec3d2b847029b24 100644 (file)
@@ -73,13 +73,26 @@ static int create_files(struct kernfs_node *parent, struct kobject *kobj,
        }
 
        if (grp->bin_attrs) {
        }
 
        if (grp->bin_attrs) {
-               for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++) {
+               for (i = 0, bin_attr = grp->bin_attrs; *bin_attr; i++, bin_attr++) {
+                       umode_t mode = (*bin_attr)->attr.mode;
+
                        if (update)
                                kernfs_remove_by_name(parent,
                                                (*bin_attr)->attr.name);
                        if (update)
                                kernfs_remove_by_name(parent,
                                                (*bin_attr)->attr.name);
+                       if (grp->is_bin_visible) {
+                               mode = grp->is_bin_visible(kobj, *bin_attr, i);
+                               if (!mode)
+                                       continue;
+                       }
+
+                       WARN(mode & ~(SYSFS_PREALLOC | 0664),
+                            "Attribute %s: Invalid permissions 0%o\n",
+                            (*bin_attr)->attr.name, mode);
+
+                       mode &= SYSFS_PREALLOC | 0664;
                        error = sysfs_add_file_mode_ns(parent,
                                        &(*bin_attr)->attr, true,
                        error = sysfs_add_file_mode_ns(parent,
                                        &(*bin_attr)->attr, true,
-                                       (*bin_attr)->attr.mode, NULL);
+                                       mode, NULL);
                        if (error)
                                break;
                }
                        if (error)
                                break;
                }