Skip to content

Commit e504a78

Browse files
Matt Fleminggregkh
Matt Fleming
authored andcommitted
efi: Pass correct file handle to efi_file_{read,close}
commit 47514c9 upstream. We're currently passing the file handle for the root file system to efi_file_read() and efi_file_close(), instead of the file handle for the file we wish to read/close. While this has worked up until now, it seems that it has only been by pure luck. Olivier explains, "The issue is the UEFI Fat driver might return the same function for 'fh->read()' and 'h->read()'. While in our case it does not work with a different implementation of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. In our case, we return a different pointer when reading a directory and reading a file." Fixing this actually clears up the two functions because we can drop one of the arguments, and instead only pass a file 'handle' argument. Reported-by: Olivier Martin <[email protected]> Reviewed-by: Olivier Martin <[email protected]> Reviewed-by: Mark Rutland <[email protected]> Cc: Leif Lindholm <[email protected]> Signed-off-by: Matt Fleming <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 45ada9f commit e504a78

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/firmware/efi/efi-stub-helper.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
468468
chunksize = EFI_READ_CHUNK_SIZE;
469469
else
470470
chunksize = size;
471-
status = efi_call_phys3(fh->read,
471+
status = efi_call_phys3(files[j].handle->read,
472472
files[j].handle,
473473
&chunksize,
474474
(void *)addr);
@@ -480,7 +480,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
480480
size -= chunksize;
481481
}
482482

483-
efi_call_phys1(fh->close, files[j].handle);
483+
efi_call_phys1(files[j].handle->close, files[j].handle);
484484
}
485485

486486
}
@@ -497,7 +497,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
497497

498498
close_handles:
499499
for (k = j; k < i; k++)
500-
efi_call_phys1(fh->close, files[k].handle);
500+
efi_call_phys1(files[k].handle->close, files[k].handle);
501501
free_files:
502502
efi_call_phys1(sys_table_arg->boottime->free_pool, files);
503503
fail:

0 commit comments

Comments
 (0)