All of lore.kernel.org
 help / color / mirror / Atom feed
* [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

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.