diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2021-04-11 06:53:04 +0200 |
---|---|---|
committer | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2021-04-17 20:01:32 +0200 |
commit | e8287b0fb2be8acf8d0412be3b4174768fef348c (patch) | |
tree | 94d72018f72b282ed10feea5fb001a81ab2e4255 /lib/efi_loader | |
parent | 7d823747c695e8638b637abd0c19434f661e50d9 (diff) | |
download | u-boot-e8287b0fb2be8acf8d0412be3b4174768fef348c.zip u-boot-e8287b0fb2be8acf8d0412be3b4174768fef348c.tar.gz u-boot-e8287b0fb2be8acf8d0412be3b4174768fef348c.tar.bz2 |
efi_loader: memory leak in efi_capsule_scan_dir()
If realloc() fails, we should free the old buffer.
Fixes: c74cd8bd08d1: ("efi_loader: capsule: add capsule_on_disk support")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'lib/efi_loader')
-rw-r--r-- | lib/efi_loader/efi_capsule.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index 9df9c35..691eda5 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -756,8 +756,11 @@ static efi_status_t efi_capsule_scan_dir(u16 ***files, unsigned int *num) tmp_size = dirent_size; ret = EFI_CALL((*dirh->read)(dirh, &tmp_size, dirent)); if (ret == EFI_BUFFER_TOO_SMALL) { + struct efi_file_info *old_dirent = dirent; + dirent = realloc(dirent, tmp_size); if (!dirent) { + dirent = old_dirent; ret = EFI_OUT_OF_RESOURCES; goto err; } |