* [PATCH] driver core: change to_subsys_private() to use container_of_const()
@ 2023-01-11 9:33 Greg Kroah-Hartman
2023-01-11 9:50 ` Rafael J. Wysocki
0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2023-01-11 9:33 UTC (permalink / raw)
To: linux-kernel; +Cc: Greg Kroah-Hartman, Rafael J. Wysocki
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" <rafael@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/base/base.h | 2 +-
drivers/base/class.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/base/base.h b/drivers/base/base.h
index 2e08258ce82e..3d1da1027206 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 86ec554cfe60..3366da9c3ff6 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;
--
2.39.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] driver core: change to_subsys_private() to use container_of_const()
2023-01-11 9:33 [PATCH] driver core: change to_subsys_private() to use container_of_const() Greg Kroah-Hartman
@ 2023-01-11 9:50 ` Rafael J. Wysocki
2023-01-11 15:09 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2023-01-11 9:50 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-kernel, Rafael J. Wysocki
On Wed, Jan 11, 2023 at 10:33 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> 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" <rafael@kernel.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Rafael J. Wysocki <rafael@kernel.org>
> ---
> drivers/base/base.h | 2 +-
> drivers/base/class.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/base.h b/drivers/base/base.h
> index 2e08258ce82e..3d1da1027206 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 86ec554cfe60..3366da9c3ff6 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;
> --
> 2.39.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] driver core: change to_subsys_private() to use container_of_const()
2023-01-11 9:50 ` Rafael J. Wysocki
@ 2023-01-11 15:09 ` Greg Kroah-Hartman
0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2023-01-11 15:09 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: linux-kernel
On Wed, Jan 11, 2023 at 10:50:49AM +0100, Rafael J. Wysocki wrote:
> On Wed, Jan 11, 2023 at 10:33 AM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > 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" <rafael@kernel.org>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> Reviewed-by: Rafael J. Wysocki <rafael@kernel.org>
Thanks for the review!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-11 15:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-11 9:33 [PATCH] driver core: change to_subsys_private() to use container_of_const() Greg Kroah-Hartman
2023-01-11 9:50 ` Rafael J. Wysocki
2023-01-11 15:09 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox