Skip to content

Commit

Permalink
efivars: handle errors from register_efivars()
Browse files Browse the repository at this point in the history
We should unwind and return an error if register_efivars() fails.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Mike Waychison <mikew@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Dan Carpenter authored and Greg Kroah-Hartman committed Apr 19, 2011
1 parent 051d51b commit 3116aab
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions drivers/firmware/efivars.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,17 +803,24 @@ efivars_init(void)
ops.set_variable = efi.set_variable;
ops.get_next_variable = efi.get_next_variable;
error = register_efivars(&__efivars, &ops, efi_kobj);
if (error)
goto err_put;

/* Don't forget the systab entry */
error = sysfs_create_group(efi_kobj, &efi_subsys_attr_group);
if (error) {
printk(KERN_ERR
"efivars: Sysfs attribute export failed with error %d.\n",
error);
unregister_efivars(&__efivars);
kobject_put(efi_kobj);
goto err_unregister;
}

return 0;

err_unregister:
unregister_efivars(&__efivars);
err_put:
kobject_put(efi_kobj);
return error;
}

Expand Down

0 comments on commit 3116aab

Please sign in to comment.