* [PATCH] platform/x86/intel/pmt: Fix kobject memory leak on init failure
@ 2025-12-23 8:40 Kaushlendra Kumar
2025-12-23 12:00 ` Ilpo Järvinen
0 siblings, 1 reply; 3+ messages in thread
From: Kaushlendra Kumar @ 2025-12-23 8:40 UTC (permalink / raw)
To: david.e.box, hansg, ilpo.jarvinen; +Cc: platform-driver-x86, Kaushlendra Kumar
When kobject_init_and_add() fails in pmt_features_discovery(), the
function returns without calling kobject_put(). This violates the
kobject API contract where kobject_put() must be called even on
initialization failure to properly release allocated resources.
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
---
drivers/platform/x86/intel/pmt/discovery.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/intel/pmt/discovery.c b/drivers/platform/x86/intel/pmt/discovery.c
index 32713a194a55..9c5b4d0e1fae 100644
--- a/drivers/platform/x86/intel/pmt/discovery.c
+++ b/drivers/platform/x86/intel/pmt/discovery.c
@@ -503,8 +503,10 @@ static int pmt_features_discovery(struct pmt_features_priv *priv,
ret = kobject_init_and_add(&feature->kobj, ktype, &priv->dev->kobj,
"%s", pmt_feature_names[feature->id]);
- if (ret)
+ if (ret) {
+ kobject_put(&feature->kobj);
return ret;
+ }
kobject_uevent(&feature->kobj, KOBJ_ADD);
pmt_features_add_feat(feature);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] platform/x86/intel/pmt: Fix kobject memory leak on init failure
2025-12-23 8:40 [PATCH] platform/x86/intel/pmt: Fix kobject memory leak on init failure Kaushlendra Kumar
@ 2025-12-23 12:00 ` Ilpo Järvinen
2025-12-24 2:56 ` Kumar, Kaushlendra
0 siblings, 1 reply; 3+ messages in thread
From: Ilpo Järvinen @ 2025-12-23 12:00 UTC (permalink / raw)
To: Kaushlendra Kumar; +Cc: david.e.box, Hans de Goede, platform-driver-x86
On Tue, 23 Dec 2025, Kaushlendra Kumar wrote:
> When kobject_init_and_add() fails in pmt_features_discovery(), the
> function returns without calling kobject_put(). This violates the
> kobject API contract where kobject_put() must be called even on
> initialization failure to properly release allocated resources.
>
> Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Hi,
Thanks, I've applied this to the review-ilpo-fixes branch but I had to add
Fixes tag myself as your submission did not contain one. In the future,
when fixing an issue, please add a Fixes tag pointing to the commit that
introduced the problem.
> ---
> drivers/platform/x86/intel/pmt/discovery.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/intel/pmt/discovery.c b/drivers/platform/x86/intel/pmt/discovery.c
> index 32713a194a55..9c5b4d0e1fae 100644
> --- a/drivers/platform/x86/intel/pmt/discovery.c
> +++ b/drivers/platform/x86/intel/pmt/discovery.c
> @@ -503,8 +503,10 @@ static int pmt_features_discovery(struct pmt_features_priv *priv,
>
> ret = kobject_init_and_add(&feature->kobj, ktype, &priv->dev->kobj,
> "%s", pmt_feature_names[feature->id]);
> - if (ret)
> + if (ret) {
> + kobject_put(&feature->kobj);
> return ret;
> + }
>
> kobject_uevent(&feature->kobj, KOBJ_ADD);
> pmt_features_add_feat(feature);
--
i.
^ permalink raw reply [flat|nested] 3+ messages in thread* RE: [PATCH] platform/x86/intel/pmt: Fix kobject memory leak on init failure
2025-12-23 12:00 ` Ilpo Järvinen
@ 2025-12-24 2:56 ` Kumar, Kaushlendra
0 siblings, 0 replies; 3+ messages in thread
From: Kumar, Kaushlendra @ 2025-12-24 2:56 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: david.e.box@linux.intel.com, Hans de Goede,
platform-driver-x86@vger.kernel.org
On Tue, 23 Dec 2025, Ilpo Järvinen wrote:
> Hi,
>
> Thanks, I've applied this to the review-ilpo-fixes branch but I had to add
> Fixes tag myself as your submission did not contain one. In the future,
> when fixing an issue, please add a Fixes tag pointing to the commit that
> introduced the problem.
Hi Ilpo,
Thank you for applying the patch and adding the Fixes tag. I'll ensure to
include it in future submissions.
Thanks,
Kaushlendra
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-12-24 2:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-23 8:40 [PATCH] platform/x86/intel/pmt: Fix kobject memory leak on init failure Kaushlendra Kumar
2025-12-23 12:00 ` Ilpo Järvinen
2025-12-24 2:56 ` Kumar, Kaushlendra
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.