diff mbox series

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

Message ID 20240904011202.2009727-2-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 and moving them to a read-only
section (from data --> text), and can increase over all security.

```
[Before]
   text   data    bss    dec    hex    filename
   3913    768      0   4681   1249    drivers/edac/edac_device_sysfs.o

[After]
   text   data    bss    dec    hex    filename
   4105    640      0   4745   1289    drivers/edac/edac_device_sysfs.o
```

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

Patch

diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
index fcebc4ffea26..9149e03f9d67 100644
--- a/drivers/edac/edac_device_sysfs.c
+++ b/drivers/edac/edac_device_sysfs.c
@@ -212,7 +212,7 @@  static void edac_device_ctrl_master_release(struct kobject *kobj)
 }
 
 /* ktype for the main (master) kobject */
-static struct kobj_type ktype_device_ctrl = {
+static const struct kobj_type ktype_device_ctrl = {
 	.release = edac_device_ctrl_master_release,
 	.sysfs_ops = &device_ctl_info_ops,
 	.default_groups = device_ctrl_groups,
@@ -397,7 +397,7 @@  static struct attribute *device_instance_attrs[] = {
 ATTRIBUTE_GROUPS(device_instance);
 
 /* The 'ktype' for each edac_dev 'instance' */
-static struct kobj_type ktype_instance_ctrl = {
+static const struct kobj_type ktype_instance_ctrl = {
 	.release = edac_device_ctrl_instance_release,
 	.sysfs_ops = &device_instance_ops,
 	.default_groups = device_instance_groups,
@@ -480,7 +480,7 @@  static struct attribute *device_block_attrs[] = {
 ATTRIBUTE_GROUPS(device_block);
 
 /* The 'ktype' for each edac_dev 'block' */
-static struct kobj_type ktype_block_ctrl = {
+static const struct kobj_type ktype_block_ctrl = {
 	.release = edac_device_ctrl_block_release,
 	.sysfs_ops = &device_block_ops,
 	.default_groups = device_block_groups,