diff mbox series

[-next,2/2] EDAC: Constify struct kobj_type for edac_pci_sysfs

Message ID 20240904011202.2009727-3-lihongbo22@huawei.com (mailing list archive)
State New
Headers show
Series EDAC: Constify struct kobj_type | expand

Commit Message

Hongbo Li Sept. 4, 2024, 1:12 a.m. UTC
These 'struct kobj_type' are not modified. They are only used in
kobject_init_and_add() which takes a 'const struct kobj_type *ktype'
parameter.

Constifying these structure (ktype_pci_instance and
ktype_edac_pci_main_kobj)and moving them to a read-only (text
section) section, and can increase over all security.

```
[Before]
   text   data    bss    dec    hex    filename
   4357    856     32   5245   147d    drivers/edac/edac_pci_sysfs.o

[After]
   text   data    bss    dec    hex    filename
   4485    760     32   5277   149d    drivers/edac/edac_pci_sysfs.o
```

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
 drivers/edac/edac_pci_sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
index 7b44afcf48db..f00efb06b3dc 100644
--- a/drivers/edac/edac_pci_sysfs.c
+++ b/drivers/edac/edac_pci_sysfs.c
@@ -143,7 +143,7 @@  static struct attribute *pci_instance_attrs[] = {
 ATTRIBUTE_GROUPS(pci_instance);
 
 /* the ktype for a pci instance */
-static struct kobj_type ktype_pci_instance = {
+static const struct kobj_type ktype_pci_instance = {
 	.release = edac_pci_instance_release,
 	.sysfs_ops = &pci_instance_ops,
 	.default_groups = pci_instance_groups,
@@ -326,7 +326,7 @@  static void edac_pci_release_main_kobj(struct kobject *kobj)
 }
 
 /* ktype struct for the EDAC PCI main kobj */
-static struct kobj_type ktype_edac_pci_main_kobj = {
+static const struct kobj_type ktype_edac_pci_main_kobj = {
 	.release = edac_pci_release_main_kobj,
 	.sysfs_ops = &edac_pci_sysfs_ops,
 	.default_groups = edac_pci_groups,