summaryrefslogtreecommitdiffstats
path: root/include/linux/kobject.h
diff options
context:
space:
mode:
authorWedson Almeida Filho <wedsonaf@google.com>2021-12-24 23:13:45 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-12-27 10:40:00 +0100
commitee6d3dd4ed48ab24b74bab3c3977b8218518247d (patch)
treef5d2c211fb55a757d64e74b2b8fcb6e7211ae19e /include/linux/kobject.h
parent67e532a42cf4c6c214ed39e33e617bca29508f4e (diff)
downloadlinux-ee6d3dd4ed48ab24b74bab3c3977b8218518247d.tar.bz2
driver core: make kobj_type constant.
This way instances of kobj_type (which contain function pointers) can be stored in .rodata, which means that they cannot be [easily/accidentally] modified at runtime. Signed-off-by: Wedson Almeida Filho <wedsonaf@google.com> Link: https://lore.kernel.org/r/20211224231345.777370-1-wedsonaf@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/kobject.h')
-rw-r--r--include/linux/kobject.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index c740062b4b1a..683172b2e094 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -66,7 +66,7 @@ struct kobject {
struct list_head entry;
struct kobject *parent;
struct kset *kset;
- struct kobj_type *ktype;
+ const struct kobj_type *ktype;
struct kernfs_node *sd; /* sysfs directory entry */
struct kref kref;
#ifdef CONFIG_DEBUG_KOBJECT_RELEASE
@@ -90,13 +90,13 @@ static inline const char *kobject_name(const struct kobject *kobj)
return kobj->name;
}
-extern void kobject_init(struct kobject *kobj, struct kobj_type *ktype);
+extern void kobject_init(struct kobject *kobj, const struct kobj_type *ktype);
extern __printf(3, 4) __must_check
int kobject_add(struct kobject *kobj, struct kobject *parent,
const char *fmt, ...);
extern __printf(4, 5) __must_check
int kobject_init_and_add(struct kobject *kobj,
- struct kobj_type *ktype, struct kobject *parent,
+ const struct kobj_type *ktype, struct kobject *parent,
const char *fmt, ...);
extern void kobject_del(struct kobject *kobj);
@@ -217,7 +217,7 @@ static inline void kset_put(struct kset *k)
kobject_put(&k->kobj);
}
-static inline struct kobj_type *get_ktype(struct kobject *kobj)
+static inline const struct kobj_type *get_ktype(struct kobject *kobj)
{
return kobj->ktype;
}