Skip to content

Commit fbc8846

Browse files
tititiou36akpm00
authored andcommitted
nilfs2: Constify struct kobj_type
'struct kobj_type' is not modified in this driver. It is only used with kobject_init_and_add() which takes a "const struct kobj_type *" parameter. Constifying this structure moves some data to a read-only section, so increase overall security. On a x86_64, with allmodconfig: Before: ====== text data bss dec hex filename 22403 4184 24 26611 67f3 fs/nilfs2/sysfs.o After: ===== text data bss dec hex filename 22723 3928 24 26675 6833 fs/nilfs2/sysfs.o Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Christophe JAILLET <[email protected]> Signed-off-by: Ryusuke Konishi <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 0f3819e commit fbc8846

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/nilfs2/sysfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static void nilfs_##name##_attr_release(struct kobject *kobj) \
5656
sg_##name##_kobj); \
5757
complete(&subgroups->sg_##name##_kobj_unregister); \
5858
} \
59-
static struct kobj_type nilfs_##name##_ktype = { \
59+
static const struct kobj_type nilfs_##name##_ktype = { \
6060
.default_groups = nilfs_##name##_groups, \
6161
.sysfs_ops = &nilfs_##name##_attr_ops, \
6262
.release = nilfs_##name##_attr_release, \
@@ -166,7 +166,7 @@ static const struct sysfs_ops nilfs_snapshot_attr_ops = {
166166
.store = nilfs_snapshot_attr_store,
167167
};
168168

169-
static struct kobj_type nilfs_snapshot_ktype = {
169+
static const struct kobj_type nilfs_snapshot_ktype = {
170170
.default_groups = nilfs_snapshot_groups,
171171
.sysfs_ops = &nilfs_snapshot_attr_ops,
172172
.release = nilfs_snapshot_attr_release,
@@ -967,7 +967,7 @@ static const struct sysfs_ops nilfs_dev_attr_ops = {
967967
.store = nilfs_dev_attr_store,
968968
};
969969

970-
static struct kobj_type nilfs_dev_ktype = {
970+
static const struct kobj_type nilfs_dev_ktype = {
971971
.default_groups = nilfs_dev_groups,
972972
.sysfs_ops = &nilfs_dev_attr_ops,
973973
.release = nilfs_dev_attr_release,

0 commit comments

Comments
 (0)