module: make module_ktype structure constant
authorThomas Weißschuh <linux@weissschuh.net>
Sat, 4 Feb 2023 05:44:46 +0000 (05:44 +0000)
committerLuis Chamberlain <mcgrof@kernel.org>
Thu, 9 Mar 2023 20:55:15 +0000 (12:55 -0800)
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 definition to prevent
modification at runtime.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
include/linux/module.h
kernel/params.c

index c0593a96e158fc5187ac6b6f729d93625518eca8..dbc9124b71bcf816101b2f7694296fa067af0b35 100644 (file)
@@ -871,7 +871,7 @@ void *dereference_module_function_descriptor(struct module *mod, void *ptr)
 
 #ifdef CONFIG_SYSFS
 extern struct kset *module_kset;
-extern struct kobj_type module_ktype;
+extern const struct kobj_type module_ktype;
 #endif /* CONFIG_SYSFS */
 
 #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
index 6e34ca89ebae7e780e0464f24578b2fd7f6c92e3..6a7548979aa9adab74ce77fe667adda5c84c9262 100644 (file)
@@ -948,7 +948,7 @@ static void module_kobj_release(struct kobject *kobj)
        complete(mk->kobj_completion);
 }
 
-struct kobj_type module_ktype = {
+const struct kobj_type module_ktype = {
        .release   =    module_kobj_release,
        .sysfs_ops =    &module_sysfs_ops,
 };