aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2014-04-10 09:11:45 -0400
committerMatt Fleming <matt.fleming@intel.com>2014-04-10 16:20:03 -0400
commit47514c996fac5e6f13ef3a4c5e23f1c5cffabb7b (patch)
treecd8abfa789364bf25eeb2edc415a16ee08a9a25d
parent7e8213c1f3acc064aef37813a39f13cbfe7c3ce7 (diff)
efi: Pass correct file handle to efi_file_{read,close}
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 <olivier.martin@arm.com> Reviewed-by: Olivier Martin <olivier.martin@arm.com> Reviewed-by: Mark Rutland <mark.rutland@arm.com> Cc: Leif Lindholm <leif.lindholm@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r--arch/x86/boot/compressed/eboot.c12
-rw-r--r--drivers/firmware/efi/efi-stub-helper.c6
2 files changed, 9 insertions, 9 deletions
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index 91d17007323b..4703a6c4b8e3 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -167,31 +167,31 @@ efi_file_size(efi_system_table_t *sys_table, void *__fh,
167} 167}
168 168
169static inline efi_status_t 169static inline efi_status_t
170efi_file_read(void *__fh, void *handle, unsigned long *size, void *addr) 170efi_file_read(void *handle, unsigned long *size, void *addr)
171{ 171{
172 unsigned long func; 172 unsigned long func;
173 173
174 if (efi_early->is64) { 174 if (efi_early->is64) {
175 efi_file_handle_64_t *fh = __fh; 175 efi_file_handle_64_t *fh = handle;
176 176
177 func = (unsigned long)fh->read; 177 func = (unsigned long)fh->read;
178 return efi_early->call(func, handle, size, addr); 178 return efi_early->call(func, handle, size, addr);
179 } else { 179 } else {
180 efi_file_handle_32_t *fh = __fh; 180 efi_file_handle_32_t *fh = handle;
181 181
182 func = (unsigned long)fh->read; 182 func = (unsigned long)fh->read;
183 return efi_early->call(func, handle, size, addr); 183 return efi_early->call(func, handle, size, addr);
184 } 184 }
185} 185}
186 186
187static inline efi_status_t efi_file_close(void *__fh, void *handle) 187static inline efi_status_t efi_file_close(void *handle)
188{ 188{
189 if (efi_early->is64) { 189 if (efi_early->is64) {
190 efi_file_handle_64_t *fh = __fh; 190 efi_file_handle_64_t *fh = handle;
191 191
192 return efi_early->call((unsigned long)fh->close, handle); 192 return efi_early->call((unsigned long)fh->close, handle);
193 } else { 193 } else {
194 efi_file_handle_32_t *fh = __fh; 194 efi_file_handle_32_t *fh = handle;
195 195
196 return efi_early->call((unsigned long)fh->close, handle); 196 return efi_early->call((unsigned long)fh->close, handle);
197 } 197 }
diff --git a/drivers/firmware/efi/efi-stub-helper.c b/drivers/firmware/efi/efi-stub-helper.c
index ff50aeebf0d9..2c41eaece2c1 100644
--- a/drivers/firmware/efi/efi-stub-helper.c
+++ b/drivers/firmware/efi/efi-stub-helper.c
@@ -397,7 +397,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
397 else 397 else
398 chunksize = size; 398 chunksize = size;
399 399
400 status = efi_file_read(fh, files[j].handle, 400 status = efi_file_read(files[j].handle,
401 &chunksize, 401 &chunksize,
402 (void *)addr); 402 (void *)addr);
403 if (status != EFI_SUCCESS) { 403 if (status != EFI_SUCCESS) {
@@ -408,7 +408,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
408 size -= chunksize; 408 size -= chunksize;
409 } 409 }
410 410
411 efi_file_close(fh, files[j].handle); 411 efi_file_close(files[j].handle);
412 } 412 }
413 413
414 } 414 }
@@ -425,7 +425,7 @@ free_file_total:
425 425
426close_handles: 426close_handles:
427 for (k = j; k < i; k++) 427 for (k = j; k < i; k++)
428 efi_file_close(fh, files[k].handle); 428 efi_file_close(files[k].handle);
429free_files: 429free_files:
430 efi_call_early(free_pool, files); 430 efi_call_early(free_pool, files);
431fail: 431fail: