Skip to contentSkip to conversation

PCI: acpiphp_ibm: add __ro_after_init to ibm_apci_table_attr

PATCH Applied Bhumika Goyal 3 participants 3 messages Dec 26, 2016 – Jan 11, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: acpiphp_ibm: add __ro_after_init to ibm_apci_table_attr

The object ibm_apci_table_attr of type bin_attribute structure is not modified after getting initialized by ibm_acpiphp_init. Apart from getting referenced in init it is also passed as an argument to the functions sysfs_{remove/create}_bin_file but both the arguments are of type const struct bin_attribute *. Therefore add __ro_after_init to its declaration.

---
 drivers/pci/hotplug/acpiphp_ibm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/hotplug/acpiphp_ibm.c +1 -1
index f6221d7..188cdfa 100644
@@ -107,7 +107,7 @@ static acpi_status __init ibm_find_acpi_device(acpi_handle handle,
 
 static acpi_handle ibm_acpi_handle;
 static struct notification ibm_note;
-static struct bin_attribute ibm_apci_table_attr = {
+static struct bin_attribute ibm_apci_table_attr __ro_after_init = {
 	    .attr = {
 		    .name = "apci_table",
 		    .mode = S_IRUGO,
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Bhumika Goyal

The object ibm_apci_table_attr of type bin_attribute structure is not modified after getting initialized by ibm_acpiphp_init. Apart from getting referenced in init it is also passed as an argument to the functions sysfs_{remove/create}_bin_file but both the arguments are of type const struct bin_attribute *. Therefore add __ro_after_init to its declaration.

---
 drivers/pci/hotplug/acpiphp_ibm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/hotplug/acpiphp_ibm.c +0 -0
index f6221d7..188cdfa 100644

drivers/pci/hotplug/acpiphp_ibm.c static acpi_status __init ibm_find_acpi_device(acpi_handle handle, · line 113

Quoted 8 lines
drivers/pci/hotplug/acpiphp_ibm.c +1 -1
@@ -107,7 +107,7 @@ static acpi_status __init ibm_find_acpi_device(acpi_handle handle,
 
 static acpi_handle ibm_acpi_handle;
 static struct notification ibm_note;
-static struct bin_attribute ibm_apci_table_attr = {
+static struct bin_attribute ibm_apci_table_attr __ro_after_init = {
            .attr = {
                    .name = "apci_table",
                    .mode = S_IRUGO,

Thanks!

-Kees

Signature · 2 lines
Kees Cook
Nexus Security
Reviewed-by Kees Cook on v1 1/1 Applied
#2 lore raw
In reply to Bhumika Goyal
Quoted 7 lines · Bhumika Goyal

The object ibm_apci_table_attr of type bin_attribute structure is not modified after getting initialized by ibm_acpiphp_init. Apart from getting referenced in init it is also passed as an argument to the functions sysfs_{remove/create}_bin_file but both the arguments are of type const struct bin_attribute *. Therefore add __ro_after_init to its declaration.

Applied to pci/hotplug for v4.11 with Kees' Reviewed-by and the following changelog:

PCI: acpiphp_ibm: Make ibm_apci_table_attr __ro_after_init

ibm_apci_table_attr is not modified after being initialized by ibm_acpiphp_init(). It is passed as an argument to the functions sysfs_{remove/create}_bin_file(), but both the arguments are const. Add __ro_after_init to its declaration.

Quoted 24 lines
---
 drivers/pci/hotplug/acpiphp_ibm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/hotplug/acpiphp_ibm.c +1 -1
index f6221d7..188cdfa 100644
@@ -107,7 +107,7 @@ static acpi_status __init ibm_find_acpi_device(acpi_handle handle,
 
 static acpi_handle ibm_acpi_handle;
 static struct notification ibm_note;
-static struct bin_attribute ibm_apci_table_attr = {
+static struct bin_attribute ibm_apci_table_attr __ro_after_init = {
 	    .attr = {
 		    .name = "apci_table",
 		    .mode = S_IRUGO,
Signature · 6 lines
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html