kernel: ksysfs: add __ro_after_init to bin_attribute structure
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
@@ -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
Quoted 7 lines · Bhumika Goyal
The object
notes_attrof typebin_attributeis not modified after getting initailized byksysfs_init. Apart from initialization inksysfs_initit is also passed as an argument to the functionsysfs_create_bin_filebut this argument is of type const. Therefore, add__ro_after_initto its declaration.Signed-off-by Bhumika Goyal <[email protected]>
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@@ -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