Skip to content

Commit 00c22b1

Browse files
kaushlenij-intel
authored andcommitted
platform/x86/intel/pmt: Fix kobject memory leak on init failure
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. Fixes: d9a0788 ("platform/x86/intel/pmt: Add PMT Discovery driver") Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com> Link: https://patch.msgid.link/20251223084041.3832933-1-kaushlendra.kumar@intel.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent 20e20b1 commit 00c22b1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/platform/x86/intel/pmt/discovery.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,10 @@ static int pmt_features_discovery(struct pmt_features_priv *priv,
503503

504504
ret = kobject_init_and_add(&feature->kobj, ktype, &priv->dev->kobj,
505505
"%s", pmt_feature_names[feature->id]);
506-
if (ret)
506+
if (ret) {
507+
kobject_put(&feature->kobj);
507508
return ret;
509+
}
508510

509511
kobject_uevent(&feature->kobj, KOBJ_ADD);
510512
pmt_features_add_feat(feature);

0 commit comments

Comments
 (0)