From: Greg Kroah-Hartman Date: Wed, 11 Jan 2023 09:33:27 +0000 (+0100) Subject: driver core: change to_subsys_private() to use container_of_const() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=7bbb89b420d9e290cb34864832de8fcdf2c140dc;p=linux.git driver core: change to_subsys_private() to use container_of_const() The macro to_subsys_private() needs to switch to using container_of_const() as it turned out to being incorrectly casting a const pointer to a non-const one. Make this change and fix up the one offending user to be correctly handling a const pointer properly. Cc: "Rafael J. Wysocki" Reviewed-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman Link: https://lore.kernel.org/r/20230111093327.3955063-1-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/base/base.h b/drivers/base/base.h index 7d4803c03d3e6..2eb722d89f106 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -53,7 +53,7 @@ struct subsys_private { struct kset glue_dirs; struct class *class; }; -#define to_subsys_private(obj) container_of(obj, struct subsys_private, subsys.kobj) +#define to_subsys_private(obj) container_of_const(obj, struct subsys_private, subsys.kobj) struct driver_private { struct kobject kobj; diff --git a/drivers/base/class.c b/drivers/base/class.c index 86ec554cfe604..3366da9c3ff6e 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -64,7 +64,7 @@ static void class_release(struct kobject *kobj) static const struct kobj_ns_type_operations *class_child_ns_type(const struct kobject *kobj) { - struct subsys_private *cp = to_subsys_private(kobj); + const struct subsys_private *cp = to_subsys_private(kobj); struct class *class = cp->class; return class->ns_type;