* [PATCH] ACPI: platform_profile: Fix memory leak in profile_class_is_visible()
@ 2025-02-12 19:30 Kurt Borja
2025-02-15 2:18 ` Mark Pearson
0 siblings, 1 reply; 5+ messages in thread
From: Kurt Borja @ 2025-02-12 19:30 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Len Brown, Ilpo Järvinen, Mark Pearson, Mario Limonciello,
Armin Wolf, Kurt Borja, Gergo Koteles, linux-acpi, linux-kernel
If class_find_device() finds a device it's reference count is
incremented. Call put_device() to drop this reference before returning.
Fixes: 77be5cacb2c2 ("ACPI: platform_profile: Create class for ACPI platform profile")
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
drivers/acpi/platform_profile.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index fc92e43d0fe9..2ad53cc6aae5 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -417,8 +417,14 @@ static int profile_class_registered(struct device *dev, const void *data)
static umode_t profile_class_is_visible(struct kobject *kobj, struct attribute *attr, int idx)
{
- if (!class_find_device(&platform_profile_class, NULL, NULL, profile_class_registered))
+ struct device *dev;
+
+ dev = class_find_device(&platform_profile_class, NULL, NULL, profile_class_registered);
+ if (!dev)
return 0;
+
+ put_device(dev);
+
return attr->mode;
}
base-commit: 3e3e377dd1f300bbdd230533686ce9c9f4f8a90d
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ACPI: platform_profile: Fix memory leak in profile_class_is_visible()
2025-02-12 19:30 [PATCH] ACPI: platform_profile: Fix memory leak in profile_class_is_visible() Kurt Borja
@ 2025-02-15 2:18 ` Mark Pearson
2025-02-18 18:07 ` Rafael J. Wysocki
0 siblings, 1 reply; 5+ messages in thread
From: Mark Pearson @ 2025-02-15 2:18 UTC (permalink / raw)
To: Kurt Borja, Rafael J. Wysocki
Cc: Len Brown, Ilpo Järvinen, Limonciello, Mario, Armin Wolf,
Gergo Koteles, linux-acpi@vger.kernel.org, linux-kernel
On Wed, Feb 12, 2025, at 2:30 PM, Kurt Borja wrote:
> If class_find_device() finds a device it's reference count is
> incremented. Call put_device() to drop this reference before returning.
>
> Fixes: 77be5cacb2c2 ("ACPI: platform_profile: Create class for ACPI
> platform profile")
> Signed-off-by: Kurt Borja <kuurtb@gmail.com>
> ---
> drivers/acpi/platform_profile.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/platform_profile.c
> b/drivers/acpi/platform_profile.c
> index fc92e43d0fe9..2ad53cc6aae5 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -417,8 +417,14 @@ static int profile_class_registered(struct device
> *dev, const void *data)
>
> static umode_t profile_class_is_visible(struct kobject *kobj, struct
> attribute *attr, int idx)
> {
> - if (!class_find_device(&platform_profile_class, NULL, NULL,
> profile_class_registered))
> + struct device *dev;
> +
> + dev = class_find_device(&platform_profile_class, NULL, NULL,
> profile_class_registered);
> + if (!dev)
> return 0;
> +
> + put_device(dev);
> +
> return attr->mode;
> }
>
>
> base-commit: 3e3e377dd1f300bbdd230533686ce9c9f4f8a90d
> --
> 2.48.1
Good find. Looks good to me.
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ACPI: platform_profile: Fix memory leak in profile_class_is_visible()
2025-02-15 2:18 ` Mark Pearson
@ 2025-02-18 18:07 ` Rafael J. Wysocki
2025-02-18 18:18 ` Kurt Borja
0 siblings, 1 reply; 5+ messages in thread
From: Rafael J. Wysocki @ 2025-02-18 18:07 UTC (permalink / raw)
To: Mark Pearson, Kurt Borja
Cc: Len Brown, Ilpo Järvinen, Limonciello, Mario, Armin Wolf,
Gergo Koteles, linux-acpi@vger.kernel.org, linux-kernel
On Sat, Feb 15, 2025 at 3:18 AM Mark Pearson <mpearson-lenovo@squebb.ca> wrote:
>
>
> On Wed, Feb 12, 2025, at 2:30 PM, Kurt Borja wrote:
> > If class_find_device() finds a device it's reference count is
> > incremented. Call put_device() to drop this reference before returning.
> >
> > Fixes: 77be5cacb2c2 ("ACPI: platform_profile: Create class for ACPI
> > platform profile")
> > Signed-off-by: Kurt Borja <kuurtb@gmail.com>
> > ---
> > drivers/acpi/platform_profile.c | 8 +++++++-
> > 1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/acpi/platform_profile.c
> > b/drivers/acpi/platform_profile.c
> > index fc92e43d0fe9..2ad53cc6aae5 100644
> > --- a/drivers/acpi/platform_profile.c
> > +++ b/drivers/acpi/platform_profile.c
> > @@ -417,8 +417,14 @@ static int profile_class_registered(struct device
> > *dev, const void *data)
> >
> > static umode_t profile_class_is_visible(struct kobject *kobj, struct
> > attribute *attr, int idx)
> > {
> > - if (!class_find_device(&platform_profile_class, NULL, NULL,
> > profile_class_registered))
> > + struct device *dev;
> > +
> > + dev = class_find_device(&platform_profile_class, NULL, NULL,
> > profile_class_registered);
> > + if (!dev)
> > return 0;
> > +
> > + put_device(dev);
> > +
> > return attr->mode;
> > }
> >
> >
> > base-commit: 3e3e377dd1f300bbdd230533686ce9c9f4f8a90d
> > --
> > 2.48.1
> Good find. Looks good to me.
> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Applied as 6.15 material, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ACPI: platform_profile: Fix memory leak in profile_class_is_visible()
2025-02-18 18:07 ` Rafael J. Wysocki
@ 2025-02-18 18:18 ` Kurt Borja
2025-02-18 18:27 ` Rafael J. Wysocki
0 siblings, 1 reply; 5+ messages in thread
From: Kurt Borja @ 2025-02-18 18:18 UTC (permalink / raw)
To: Rafael J. Wysocki, Mark Pearson
Cc: Len Brown, Ilpo Järvinen, Limonciello, Mario, Armin Wolf,
Gergo Koteles, linux-acpi@vger.kernel.org, linux-kernel
On Tue Feb 18, 2025 at 1:07 PM -05, Rafael J. Wysocki wrote:
> On Sat, Feb 15, 2025 at 3:18 AM Mark Pearson <mpearson-lenovo@squebb.ca> wrote:
>>
>>
>> On Wed, Feb 12, 2025, at 2:30 PM, Kurt Borja wrote:
>> > If class_find_device() finds a device it's reference count is
>> > incremented. Call put_device() to drop this reference before returning.
>> >
>> > Fixes: 77be5cacb2c2 ("ACPI: platform_profile: Create class for ACPI
>> > platform profile")
>> > Signed-off-by: Kurt Borja <kuurtb@gmail.com>
>> > ---
>> > drivers/acpi/platform_profile.c | 8 +++++++-
>> > 1 file changed, 7 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/acpi/platform_profile.c
>> > b/drivers/acpi/platform_profile.c
>> > index fc92e43d0fe9..2ad53cc6aae5 100644
>> > --- a/drivers/acpi/platform_profile.c
>> > +++ b/drivers/acpi/platform_profile.c
>> > @@ -417,8 +417,14 @@ static int profile_class_registered(struct device
>> > *dev, const void *data)
>> >
>> > static umode_t profile_class_is_visible(struct kobject *kobj, struct
>> > attribute *attr, int idx)
>> > {
>> > - if (!class_find_device(&platform_profile_class, NULL, NULL,
>> > profile_class_registered))
>> > + struct device *dev;
>> > +
>> > + dev = class_find_device(&platform_profile_class, NULL, NULL,
>> > profile_class_registered);
>> > + if (!dev)
>> > return 0;
>> > +
>> > + put_device(dev);
>> > +
>> > return attr->mode;
>> > }
>> >
>> >
>> > base-commit: 3e3e377dd1f300bbdd230533686ce9c9f4f8a90d
>> > --
>> > 2.48.1
>> Good find. Looks good to me.
>> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>
> Applied as 6.15 material, thanks!
Hi Rafael,
Thank you!
I believe this should be merged as a fix for v6.14-rc4 before
commit 77be5cacb2c2 hits stable.
--
~ Kurt
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ACPI: platform_profile: Fix memory leak in profile_class_is_visible()
2025-02-18 18:18 ` Kurt Borja
@ 2025-02-18 18:27 ` Rafael J. Wysocki
0 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2025-02-18 18:27 UTC (permalink / raw)
To: Kurt Borja
Cc: Rafael J. Wysocki, Mark Pearson, Len Brown, Ilpo Järvinen,
Limonciello, Mario, Armin Wolf, Gergo Koteles,
linux-acpi@vger.kernel.org, linux-kernel
On Tue, Feb 18, 2025 at 7:18 PM Kurt Borja <kuurtb@gmail.com> wrote:
>
> On Tue Feb 18, 2025 at 1:07 PM -05, Rafael J. Wysocki wrote:
> > On Sat, Feb 15, 2025 at 3:18 AM Mark Pearson <mpearson-lenovo@squebb.ca> wrote:
> >>
> >>
> >> On Wed, Feb 12, 2025, at 2:30 PM, Kurt Borja wrote:
> >> > If class_find_device() finds a device it's reference count is
> >> > incremented. Call put_device() to drop this reference before returning.
> >> >
> >> > Fixes: 77be5cacb2c2 ("ACPI: platform_profile: Create class for ACPI
> >> > platform profile")
> >> > Signed-off-by: Kurt Borja <kuurtb@gmail.com>
> >> > ---
> >> > drivers/acpi/platform_profile.c | 8 +++++++-
> >> > 1 file changed, 7 insertions(+), 1 deletion(-)
> >> >
> >> > diff --git a/drivers/acpi/platform_profile.c
> >> > b/drivers/acpi/platform_profile.c
> >> > index fc92e43d0fe9..2ad53cc6aae5 100644
> >> > --- a/drivers/acpi/platform_profile.c
> >> > +++ b/drivers/acpi/platform_profile.c
> >> > @@ -417,8 +417,14 @@ static int profile_class_registered(struct device
> >> > *dev, const void *data)
> >> >
> >> > static umode_t profile_class_is_visible(struct kobject *kobj, struct
> >> > attribute *attr, int idx)
> >> > {
> >> > - if (!class_find_device(&platform_profile_class, NULL, NULL,
> >> > profile_class_registered))
> >> > + struct device *dev;
> >> > +
> >> > + dev = class_find_device(&platform_profile_class, NULL, NULL,
> >> > profile_class_registered);
> >> > + if (!dev)
> >> > return 0;
> >> > +
> >> > + put_device(dev);
> >> > +
> >> > return attr->mode;
> >> > }
> >> >
> >> >
> >> > base-commit: 3e3e377dd1f300bbdd230533686ce9c9f4f8a90d
> >> > --
> >> > 2.48.1
> >> Good find. Looks good to me.
> >> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> >
> > Applied as 6.15 material, thanks!
>
> Hi Rafael,
>
> Thank you!
>
> I believe this should be merged as a fix for v6.14-rc4 before
> commit 77be5cacb2c2 hits stable.
I can queue it up for 6.14-rc, but that may not prevent 77be5cacb2c2
from going into -stable before it.
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-02-18 18:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-12 19:30 [PATCH] ACPI: platform_profile: Fix memory leak in profile_class_is_visible() Kurt Borja
2025-02-15 2:18 ` Mark Pearson
2025-02-18 18:07 ` Rafael J. Wysocki
2025-02-18 18:18 ` Kurt Borja
2025-02-18 18:27 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox