From: Kurt Borja <kuurtb@gmail.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: "Len Brown" <lenb@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Mark Pearson" <mpearson-lenovo@squebb.ca>,
"Mario Limonciello" <mario.limonciello@amd.com>,
"Armin Wolf" <W_Armin@gmx.de>, "Kurt Borja" <kuurtb@gmail.com>,
"Gergo Koteles" <soyer@irl.hu>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ACPI: platform_profile: Fix memory leak in profile_class_is_visible()
Date: Wed, 12 Feb 2025 14:30:58 -0500 [thread overview]
Message-ID: <20250212193058.32110-1-kuurtb@gmail.com> (raw)
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
next reply other threads:[~2025-02-12 19:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-12 19:30 Kurt Borja [this message]
2025-02-15 2:18 ` [PATCH] ACPI: platform_profile: Fix memory leak in profile_class_is_visible() 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250212193058.32110-1-kuurtb@gmail.com \
--to=kuurtb@gmail.com \
--cc=W_Armin@gmx.de \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=mpearson-lenovo@squebb.ca \
--cc=rafael@kernel.org \
--cc=soyer@irl.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox