Skip to content

Commit d8bd8c6

Browse files
committed
efi/efivars: Add missing kobject_put() in sysfs entry creation error path
The documentation provided by kobject_init_and_add() clearly spells out the need to call kobject_put() on the kobject if an error is returned. Add this missing call to the error path. Cc: <[email protected]> Reported-by: 亿一 <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent 27cd551 commit d8bd8c6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/firmware/efi/efivars.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,10 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
522522
ret = kobject_init_and_add(&new_var->kobj, &efivar_ktype,
523523
NULL, "%s", short_name);
524524
kfree(short_name);
525-
if (ret)
525+
if (ret) {
526+
kobject_put(&new_var->kobj);
526527
return ret;
528+
}
527529

528530
kobject_uevent(&new_var->kobj, KOBJ_ADD);
529531
if (efivar_entry_add(new_var, &efivar_sysfs_list)) {

0 commit comments

Comments
 (0)