diff mbox series

acpi: verify file entries in bios_linker_loader_add_pointer()

Message ID 1553199229-25318-1-git-send-email-liam.merwick@oracle.com (mailing list archive)
State New, archived
Headers show
Series acpi: verify file entries in bios_linker_loader_add_pointer() | expand

Commit Message

Liam Merwick March 21, 2019, 8:13 p.m. UTC
The callers to bios_linker_find_file() assert that the file entry returned
is not NULL, except for those in bios_linker_loader_add_pointer().  Add two
asserts in that case for completeness and to facilitate static code analysis.

Signed-off-by: Liam Merwick <liam.merwick@oracle.com>
---
 hw/acpi/bios-linker-loader.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Igor Mammedov March 22, 2019, 12:17 p.m. UTC | #1
On Thu, 21 Mar 2019 20:13:49 +0000
Liam Merwick <liam.merwick@oracle.com> wrote:

> The callers to bios_linker_find_file() assert that the file entry returned
> is not NULL, except for those in bios_linker_loader_add_pointer().  Add two
> asserts in that case for completeness and to facilitate static code analysis.
> 
> Signed-off-by: Liam Merwick <liam.merwick@oracle.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  hw/acpi/bios-linker-loader.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/hw/acpi/bios-linker-loader.c b/hw/acpi/bios-linker-loader.c
> index d16b8bbcb187..626c04a39f92 100644
> --- a/hw/acpi/bios-linker-loader.c
> +++ b/hw/acpi/bios-linker-loader.c
> @@ -283,6 +283,8 @@ void bios_linker_loader_add_pointer(BIOSLinker *linker,
>      const BiosLinkerFileEntry *source_file =
>          bios_linker_find_file(linker, src_file);
>  
> +    assert(dst_file);
> +    assert(source_file);
>      assert(dst_patched_offset < dst_file->blob->len);
>      assert(dst_patched_offset + dst_patched_size <= dst_file->blob->len);
>      assert(src_offset < source_file->blob->len);
diff mbox series

Patch

diff --git a/hw/acpi/bios-linker-loader.c b/hw/acpi/bios-linker-loader.c
index d16b8bbcb187..626c04a39f92 100644
--- a/hw/acpi/bios-linker-loader.c
+++ b/hw/acpi/bios-linker-loader.c
@@ -283,6 +283,8 @@  void bios_linker_loader_add_pointer(BIOSLinker *linker,
     const BiosLinkerFileEntry *source_file =
         bios_linker_find_file(linker, src_file);
 
+    assert(dst_file);
+    assert(source_file);
     assert(dst_patched_offset < dst_file->blob->len);
     assert(dst_patched_offset + dst_patched_size <= dst_file->blob->len);
     assert(src_offset < source_file->blob->len);