Skip to contentSkip to conversation

fix: edac: edac_device_create_instance: main_kobj reference leaked on success and block-creation error paths

PATCH In review WenTao Liang 1 participant 2 messages Jun 26 – Jun 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix: edac: edac_device_create_instance: main_kobj reference leaked on success and block-creation error paths

kobject_get(&edac_dev->kobj) acquires a reference on main_kobj, but it is
only released when kobject_init_and_add fails. The success path and the block-creation error path both return without calling kobject_put(main_kobj), leaking the edac_dev kobject reference. The main_kobj pointer is local and lost after function return.

Fixes c10997f6575f ("Kobject: convert drivers/* from kobject_unregister() to kobject_put()")
---
 drivers/edac/edac_device_sysfs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/edac/edac_device_sysfs.c +1 -0
index b1c2717cd023..72b06d608b98 100644
@@ -647,6 +647,7 @@ static int edac_device_create_instance(struct edac_device_ctl_info *edac_dev,
 
 	/* error unwind stack */
 err_release_instance_kobj:
+	kobject_put(main_kobj);
 	kobject_put(&instance->kobj);
 
 err_out:
Signature · 1 line
2.39.5 (Apple Git-154)
#1 lore raw
Quoted 28 lines

2026年6月26日 20:35,WenTao Liang <[email protected]> 写道:

kobject_get(&edac_dev->kobj) acquires a reference on main_kobj, but it is
only released when kobject_init_and_add fails. The success path and the block-creation error path both return without calling kobject_put(main_kobj), leaking the edac_dev kobject reference. The main_kobj pointer is local and lost after function return.

Fixes c10997f6575f ("Kobject: convert drivers/* from kobject_unregister() to kobject_put()")

---
drivers/edac/edac_device_sysfs.c | 1 +

1 file changed, 1 insertion(+)
drivers/edac/edac_device_sysfs.c +0 -0
index b1c2717cd023..72b06d608b98 100644
@@ -647,6 +647,7 @@ static int edac_device_create_instance(struct edac_device_ctl_info *edac_dev,
 
 	/* error unwind stack */

err_release_instance_kobj:

drivers/edac/edac_device_sysfs.c +1 -0
+	kobject_put(main_kobj);
	kobject_put(&instance->kobj);
Quoted 3 lines

err_out:

Signature · 1 line
2.39.5 (Apple Git-154)

Please ignore this patch. I will resend a proper version after learning the kernel submission process.

Apologies for the noise.

Best regards,
WenTao Liang