Skip to contentSkip to conversation

kernel: ksysfs: add __ro_after_init to bin_attribute structure

PATCH Applied Bhumika Goyal 2 participants 2 messages Feb 11, 2017 – Feb 13, 2017 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel: ksysfs: add __ro_after_init to bin_attribute structure

The object notes_attr of type bin_attribute is not modified after getting initailized by ksysfs_init. Apart from initialization in ksysfs_init it is also passed as an argument to the function sysfs_create_bin_file but this argument is of type const. Therefore, add __ro_after_init to its declaration.

---
 kernel/ksysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/ksysfs.c +1 -1
index ee1bc1b..0999679 100644
@@ -195,7 +195,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
 	return count;
 }
 
-static struct bin_attribute notes_attr = {
+static struct bin_attribute notes_attr __ro_after_init  = {
 	.attr = {
 		.name = "notes",
 		.mode = S_IRUGO,
Signature · 1 line
1.9.1
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Bhumika Goyal

The object notes_attr of type bin_attribute is not modified after getting initailized by ksysfs_init. Apart from initialization in ksysfs_init it is also passed as an argument to the function sysfs_create_bin_file but this argument is of type const. Therefore, add __ro_after_init to its declaration.

Looks good to me.

It looks like akpm historically carries changes in this area?

-Kees

Quoted 20 lines
---
 kernel/ksysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/ksysfs.c +1 -2
index ee1bc1b..0999679 100644
@@ -195,7 +195,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
        return count;
 }
 
-static struct bin_attribute notes_attr = {
+static struct bin_attribute notes_attr __ro_after_init  = {
        .attr = {
                .name = "notes",
                .mode = S_IRUGO,
--

1.9.1

Signature · 2 lines
Kees Cook
Pixel Security