diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2020-07-17 00:20:14 +0200 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2020-07-25 14:46:57 -0600 |
commit | 331caeafad40dd457dbc669c05a9e0d8ebc7095f (patch) | |
tree | 543e3a0e9bca963b12b3a1eb94548db76bc397aa /test/dm/acpi.c | |
parent | 5ab71ea4b18dce9fe5599075c4309ea39b62954f (diff) | |
download | u-boot-331caeafad40dd457dbc669c05a9e0d8ebc7095f.tar.gz |
test/dm: check if devices exist
Running 'ut dm' on the sandbox without -D or -d results in segmentation
faults due to NULL pointer dereferences.
Check that device pointers are non-NULL before using them.
Use ut_assertnonnull() for pointers instead of ut_assert().
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Philippe Reynes <philippe.reynes@softathome.com>
Diffstat (limited to 'test/dm/acpi.c')
-rw-r--r-- | test/dm/acpi.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/test/dm/acpi.c b/test/dm/acpi.c index b94c4ba4d1..bb8550ffb1 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -190,7 +190,10 @@ DM_TEST(dm_test_acpi_get_table_revision, static int dm_test_acpi_create_dmar(struct unit_test_state *uts) { struct acpi_dmar dmar; + struct udevice *cpu; + ut_assertok(uclass_first_device(UCLASS_CPU, &cpu)); + ut_assertnonnull(cpu); ut_assertok(acpi_create_dmar(&dmar, DMAR_INTR_REMAP)); ut_asserteq(DMAR_INTR_REMAP, dmar.flags); ut_asserteq(32 - 1, dmar.host_address_width); |