Skip to contentSkip to conversation

lightnvm: pblk: Fix kobject memleak

PATCH New Wang Hai 1 participant 1 message Jun 2, 2020 Block layer

lore
Share & tools
lore

Wang Hai

author
#0 lore raw

PATCH 1/1 lightnvm: pblk: Fix kobject memleak

Currently the error return path from kobject_init_and_add() is not followed by a call to kobject_put() - which means we are leaking the kobject.

Fix it by adding a call to kobject_put() in the error path of kobject_init_and_add().

Fixes a4bd217b4326 ("lightnvm: physical block device (pblk) target")
---
 drivers/lightnvm/pblk-sysfs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/lightnvm/pblk-sysfs.c +1 -0
index 6387302..a8cb89b 100644
@@ -710,6 +710,7 @@ int pblk_sysfs_init(struct gendisk *tdisk)
 					kobject_get(&parent_dev->kobj),
 					"%s", "pblk");
 	if (ret) {
+		kobject_put(&pblk->kobj);
 		pblk_err(pblk, "could not register\n");
 		return ret;
 	}
Signature · 1 line
1.8.3.1