Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kobject: make dynamic_kobj_ktype and kset_ktype const

Since commit ee6d3dd4ed48 ("driver core: make kobj_type constant.")
the driver core allows the usage of const struct kobj_type.

Take advantage of this to constify the structure definitions to prevent
modification at runtime.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/20230204-kobj_type-kobj-v1-1-ddd1b4ef8ab5@weissschuh.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Thomas Weißschuh and committed by
Greg Kroah-Hartman
dda6b81f 8518e9db

+2 -2
+2 -2
lib/kobject.c
··· 737 737 kfree(kobj); 738 738 } 739 739 740 - static struct kobj_type dynamic_kobj_ktype = { 740 + static const struct kobj_type dynamic_kobj_ktype = { 741 741 .release = dynamic_kobj_release, 742 742 .sysfs_ops = &kobj_sysfs_ops, 743 743 }; ··· 921 921 kobject_get_ownership(kobj->parent, uid, gid); 922 922 } 923 923 924 - static struct kobj_type kset_ktype = { 924 + static const struct kobj_type kset_ktype = { 925 925 .sysfs_ops = &kobj_sysfs_ops, 926 926 .release = kset_release, 927 927 .get_ownership = kset_get_ownership,