Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: d9a078809356 ("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>

authored by

Kaushlendra Kumar and committed by
Ilpo Järvinen
00c22b1e 20e20b14

+3 -1
+3 -1
drivers/platform/x86/intel/pmt/discovery.c
··· 503 503 504 504 ret = kobject_init_and_add(&feature->kobj, ktype, &priv->dev->kobj, 505 505 "%s", pmt_feature_names[feature->id]); 506 - if (ret) 506 + if (ret) { 507 + kobject_put(&feature->kobj); 507 508 return ret; 509 + } 508 510 509 511 kobject_uevent(&feature->kobj, KOBJ_ADD); 510 512 pmt_features_add_feat(feature);