Commit f078e060 authored by Qiushi Wu's avatar Qiushi Wu Committed by Kelsey Skunberg

efi/esrt: Fix reference count leak in esre_create_sysfs_entry.

BugLink: https://bugs.launchpad.net/bugs/1885932

[ Upstream commit 4ddf4739 ]

kobject_init_and_add() takes reference even when it fails.
If this function returns an error, kobject_put() must be called to
properly clean up the memory associated with the object. Previous
commit "b8eb7183" fixed a similar problem.

Fixes: 0bb54905 ("efi: Add esrt support")
Signed-off-by: default avatarQiushi Wu <wu000273@umn.edu>
Link: https://lore.kernel.org/r/20200528183804.4497-1-wu000273@umn.eduSigned-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
Signed-off-by: default avatarKelsey Skunberg <kelsey.skunberg@canonical.com>
parent d56b9e5b
...@@ -182,7 +182,7 @@ static int esre_create_sysfs_entry(void *esre, int entry_num) ...@@ -182,7 +182,7 @@ static int esre_create_sysfs_entry(void *esre, int entry_num)
rc = kobject_init_and_add(&entry->kobj, &esre1_ktype, NULL, rc = kobject_init_and_add(&entry->kobj, &esre1_ktype, NULL,
"%s", name); "%s", name);
if (rc) { if (rc) {
kfree(entry); kobject_put(&entry->kobj);
return rc; return rc;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment