Skip to content

Commit 7492ca3

Browse files
hsiaoh2mpe
authored andcommitted
powerpc: powernv: Constify struct kobj_type
'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 3775 256 8 4039 fc7 arch/powerpc/platforms/powernv/opal-dump.o 2679 260 8 2947 b83 arch/powerpc/platforms/powernv/opal-elog.o After: ====== text data bss dec hex filename 3823 208 8 4039 fc7 arch/powerpc/platforms/powernv/opal-dump.o 2727 212 8 2947 b83 arch/powerpc/platforms/powernv/opal-elog.o Signed-off-by: Huang Xiaojia <huangxiaojia2@huawei.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20240826150957.3500237-2-huangxiaojia2@huawei.com
1 parent 7509c23 commit 7492ca3

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

arch/powerpc/platforms/powernv/opal-dump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static struct attribute *dump_default_attrs[] = {
210210
};
211211
ATTRIBUTE_GROUPS(dump_default);
212212

213-
static struct kobj_type dump_ktype = {
213+
static const struct kobj_type dump_ktype = {
214214
.sysfs_ops = &dump_sysfs_ops,
215215
.release = &dump_release,
216216
.default_groups = dump_default_groups,

arch/powerpc/platforms/powernv/opal-elog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static struct attribute *elog_default_attrs[] = {
146146
};
147147
ATTRIBUTE_GROUPS(elog_default);
148148

149-
static struct kobj_type elog_ktype = {
149+
static const struct kobj_type elog_ktype = {
150150
.sysfs_ops = &elog_sysfs_ops,
151151
.release = &elog_release,
152152
.default_groups = elog_default_groups,

0 commit comments

Comments
 (0)