Skip to content

Commit 7bbb89b

Browse files
committed
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" <[email protected]> Reviewed-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3bb2a01 commit 7bbb89b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

drivers/base/base.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct subsys_private {
5353
struct kset glue_dirs;
5454
struct class *class;
5555
};
56-
#define to_subsys_private(obj) container_of(obj, struct subsys_private, subsys.kobj)
56+
#define to_subsys_private(obj) container_of_const(obj, struct subsys_private, subsys.kobj)
5757

5858
struct driver_private {
5959
struct kobject kobj;

drivers/base/class.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static void class_release(struct kobject *kobj)
6464

6565
static const struct kobj_ns_type_operations *class_child_ns_type(const struct kobject *kobj)
6666
{
67-
struct subsys_private *cp = to_subsys_private(kobj);
67+
const struct subsys_private *cp = to_subsys_private(kobj);
6868
struct class *class = cp->class;
6969

7070
return class->ns_type;

0 commit comments

Comments
 (0)