| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * efibc: control EFI bootloaders which obey LoaderEntryOneShot var |
|---|
| 3 | 4 | * Copyright (c) 2013-2016, Intel Corporation. |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 6 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 7 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 10 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 11 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 12 | | - * more details. |
|---|
| 13 | 5 | */ |
|---|
| 14 | 6 | |
|---|
| 15 | 7 | #define pr_fmt(fmt) "efibc: " fmt |
|---|
| .. | .. |
|---|
| 51 | 43 | efibc_str_to_str16(value, (efi_char16_t *)entry->var.Data); |
|---|
| 52 | 44 | memcpy(&entry->var.VendorGuid, &guid, sizeof(guid)); |
|---|
| 53 | 45 | |
|---|
| 54 | | - ret = efivar_entry_set(entry, |
|---|
| 55 | | - EFI_VARIABLE_NON_VOLATILE |
|---|
| 56 | | - | EFI_VARIABLE_BOOTSERVICE_ACCESS |
|---|
| 57 | | - | EFI_VARIABLE_RUNTIME_ACCESS, |
|---|
| 58 | | - size, entry->var.Data, NULL); |
|---|
| 46 | + ret = efivar_entry_set_safe(entry->var.VariableName, |
|---|
| 47 | + entry->var.VendorGuid, |
|---|
| 48 | + EFI_VARIABLE_NON_VOLATILE |
|---|
| 49 | + | EFI_VARIABLE_BOOTSERVICE_ACCESS |
|---|
| 50 | + | EFI_VARIABLE_RUNTIME_ACCESS, |
|---|
| 51 | + false, size, entry->var.Data); |
|---|
| 52 | + |
|---|
| 59 | 53 | if (ret) |
|---|
| 60 | 54 | pr_err("failed to set %s EFI variable: 0x%x\n", |
|---|
| 61 | 55 | name, ret); |
|---|
| .. | .. |
|---|
| 90 | 84 | { |
|---|
| 91 | 85 | int ret; |
|---|
| 92 | 86 | |
|---|
| 93 | | - if (!efi_enabled(EFI_RUNTIME_SERVICES)) |
|---|
| 87 | + if (!efivars_kobject() || !efivar_supports_writes()) |
|---|
| 94 | 88 | return -ENODEV; |
|---|
| 95 | 89 | |
|---|
| 96 | 90 | ret = register_reboot_notifier(&efibc_reboot_notifier); |
|---|