diff options
Diffstat (limited to 'samples/kobject/kset-example.c')
| -rw-r--r-- | samples/kobject/kset-example.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/samples/kobject/kset-example.c b/samples/kobject/kset-example.c index 3b126d1f859..ab5e447ec23 100644 --- a/samples/kobject/kset-example.c +++ b/samples/kobject/kset-example.c @@ -10,6 +10,7 @@ #include <linux/kobject.h> #include <linux/string.h> #include <linux/sysfs.h> +#include <linux/slab.h> #include <linux/module.h> #include <linux/init.h> @@ -123,8 +124,9 @@ static ssize_t foo_store(struct foo_obj *foo_obj, struct foo_attribute *attr, return count; } +/* Sysfs attributes cannot be world-writable. */ static struct foo_attribute foo_attribute = - __ATTR(foo, 0666, foo_show, foo_store); + __ATTR(foo, 0664, foo_show, foo_store); /* * More complex function where we determine which variable is being accessed by @@ -156,9 +158,9 @@ static ssize_t b_store(struct foo_obj *foo_obj, struct foo_attribute *attr, } static struct foo_attribute baz_attribute = - __ATTR(baz, 0666, b_show, b_store); + __ATTR(baz, 0664, b_show, b_store); static struct foo_attribute bar_attribute = - __ATTR(bar, 0666, b_show, b_store); + __ATTR(bar, 0664, b_show, b_store); /* * Create a group of attributes so that we can create and destroy them all @@ -261,6 +263,7 @@ baz_error: bar_error: destroy_foo_obj(foo_obj); foo_error: + kset_unregister(example_kset); return -EINVAL; } |
