Commit 0217a40d authored by Johan Hovold's avatar Johan Hovold Committed by Ard Biesheuvel

efi: efivars: prevent double registration

Add the missing sanity check to efivars_register() so that it is no
longer possible to override an already registered set of efivar ops
(without first deregistering them).

This can help debug initialisation ordering issues where drivers have so
far unknowingly been relying on overriding the generic ops.
Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
parent bad267f9
......@@ -62,18 +62,27 @@ EXPORT_SYMBOL_GPL(efivar_is_available);
int efivars_register(struct efivars *efivars,
const struct efivar_operations *ops)
{
int rv;
if (down_interruptible(&efivars_lock))
return -EINTR;
if (__efivars) {
pr_warn("efivars already registered\n");
rv = -EBUSY;
goto out;
}
efivars->ops = ops;
__efivars = efivars;
pr_info("Registered efivars operations\n");
rv = 0;
out:
up(&efivars_lock);
return 0;
return rv;
}
EXPORT_SYMBOL_GPL(efivars_register);
......
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