Skip to content

Commit 4ddf473

Browse files
QiushiWuardbiesheuvel
authored andcommitted
efi/esrt: Fix reference count leak in esre_create_sysfs_entry.
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 "b8eb718348b8" fixed a similar problem. Fixes: 0bb5490 ("efi: Add esrt support") Signed-off-by: Qiushi Wu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent 7dfc06a commit 4ddf473

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/firmware/efi/esrt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static int esre_create_sysfs_entry(void *esre, int entry_num)
181181
rc = kobject_init_and_add(&entry->kobj, &esre1_ktype, NULL,
182182
"entry%d", entry_num);
183183
if (rc) {
184-
kfree(entry);
184+
kobject_put(&entry->kobj);
185185
return rc;
186186
}
187187
}

0 commit comments

Comments
 (0)