diff mbox series

[-next,3/3] powerpc: pseries: Constify struct kobj_type

Message ID 20240826150957.3500237-3-huangxiaojia2@huawei.com (mailing list archive)
State Accepted
Commit 6f2683274d0d0b51a986f73c2afb9058156f1641
Headers show
Series [-next,1/3] powerpc: Constify struct kobj_type | expand

Checks

Context Check Description
snowpatch_ozlabs/github-powerpc_ppctests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_selftests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_sparse success Successfully ran 4 jobs.
snowpatch_ozlabs/github-powerpc_clang success Successfully ran 5 jobs.
snowpatch_ozlabs/github-powerpc_kernel_qemu success Successfully ran 21 jobs.

Commit Message

Huang Xiaojia Aug. 26, 2024, 3:09 p.m. UTC
'struct kobj_type' is not modified. It is only used in kobject_init()
which takes a 'const struct kobj_type *ktype' parameter.

Constifying this structure moves some data to a read-only section,
so increase over all security.

On a x86_64, compiled with ppc64 defconfig:
Before:
======
   text	   data	    bss	    dec	    hex	filename
   1885	    368	     16	   2269	    8dd	arch/powerpc/platforms/pseries/vas-sysfs.o

After:
======
   text	   data	    bss	    dec	    hex	filename
   1981	    272	     16	   2269	    8dd	arch/powerpc/platforms/pseries/vas-sysfs.o

Signed-off-by: Huang Xiaojia <huangxiaojia2@huawei.com>
---
 arch/powerpc/platforms/pseries/vas-sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/arch/powerpc/platforms/pseries/vas-sysfs.c b/arch/powerpc/platforms/pseries/vas-sysfs.c
index f9f682724e77..9e05a0e99cad 100644
--- a/arch/powerpc/platforms/pseries/vas-sysfs.c
+++ b/arch/powerpc/platforms/pseries/vas-sysfs.c
@@ -162,13 +162,13 @@  static const struct sysfs_ops vas_sysfs_ops = {
 	.store	=	vas_type_store,
 };
 
-static struct kobj_type vas_def_attr_type = {
+static const struct kobj_type vas_def_attr_type = {
 		.release	=	vas_type_release,
 		.sysfs_ops      =       &vas_sysfs_ops,
 		.default_groups	=	vas_def_capab_groups,
 };
 
-static struct kobj_type vas_qos_attr_type = {
+static const struct kobj_type vas_qos_attr_type = {
 		.release	=	vas_type_release,
 		.sysfs_ops	=	&vas_sysfs_ops,
 		.default_groups	=	vas_qos_capab_groups,