diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2018-12-22 00:37:41 +0100 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2018-12-23 02:04:25 +0100 |
commit | 05aceb2b1c9d88aafcb8dfbedb24742a24d986ba (patch) | |
tree | 0e1bf07eb0283cfc68f5de4ffa72932c944b85d4 | |
parent | 1f2e948d6d53f77a2ddb2dde3531b0d5bc2815ad (diff) | |
download | u-boot-05aceb2b1c9d88aafcb8dfbedb24742a24d986ba.tar.gz |
efi_selftest: block device: avoid read after free
Reading the position in a file after closing the same results in a read
after free.
Correct the sequence in the test.
Reported-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
-rw-r--r-- | lib/efi_selftest/efi_selftest_block_device.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/efi_selftest/efi_selftest_block_device.c b/lib/efi_selftest/efi_selftest_block_device.c index d4e4fac1c7..f038da9f19 100644 --- a/lib/efi_selftest/efi_selftest_block_device.c +++ b/lib/efi_selftest/efi_selftest_block_device.c @@ -445,11 +445,6 @@ static int execute(void) efi_st_error("Failed to write file\n"); return EFI_ST_FAILURE; } - ret = file->close(file); - if (ret != EFI_SUCCESS) { - efi_st_error("Failed to close file\n"); - return EFI_ST_FAILURE; - } ret = file->getpos(file, &pos); if (ret != EFI_SUCCESS) { efi_st_error("GetPosition failed\n"); @@ -460,6 +455,11 @@ static int execute(void) (unsigned int)pos); return EFI_ST_FAILURE; } + ret = file->close(file); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to close file\n"); + return EFI_ST_FAILURE; + } /* Verify file */ boottime->set_mem(buf, sizeof(buf), 0); |