Skip to content

Commit 7c23b18

Browse files
guilhermepiccoliardbiesheuvel
authored andcommitted
efi: pstore: Return proper errors on UEFI failures
Right now efi-pstore either returns 0 (success) or -EIO; but we do have a function to convert UEFI errors in different standard error codes, helping to narrow down potential issues more accurately. So, let's use this helper here. Signed-off-by: Guilherme G. Piccoli <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent 5134acb commit 7c23b18

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/firmware/efi/efi-pstore.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static int efi_pstore_read_func(struct pstore_record *record,
136136
&size, record->buf);
137137
if (status != EFI_SUCCESS) {
138138
kfree(record->buf);
139-
return -EIO;
139+
return efi_status_to_err(status);
140140
}
141141

142142
/*
@@ -189,7 +189,7 @@ static ssize_t efi_pstore_read(struct pstore_record *record)
189189
return 0;
190190

191191
if (status != EFI_SUCCESS)
192-
return -EIO;
192+
return efi_status_to_err(status);
193193

194194
/* skip variables that don't concern us */
195195
if (efi_guidcmp(guid, LINUX_EFI_CRASH_GUID))
@@ -227,7 +227,7 @@ static int efi_pstore_write(struct pstore_record *record)
227227
record->size, record->psi->buf,
228228
true);
229229
efivar_unlock();
230-
return status == EFI_SUCCESS ? 0 : -EIO;
230+
return efi_status_to_err(status);
231231
};
232232

233233
static int efi_pstore_erase(struct pstore_record *record)
@@ -238,7 +238,7 @@ static int efi_pstore_erase(struct pstore_record *record)
238238
PSTORE_EFI_ATTRIBUTES, 0, NULL);
239239

240240
if (status != EFI_SUCCESS && status != EFI_NOT_FOUND)
241-
return -EIO;
241+
return efi_status_to_err(status);
242242
return 0;
243243
}
244244

0 commit comments

Comments
 (0)