summaryrefslogtreecommitdiff
path: root/test/dm/acpi.c
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2020-07-17 01:20:14 +0300
committerSimon Glass <sjg@chromium.org>2020-07-20 20:37:47 +0300
commit105da6251a16cfc5db1ef374b5a18ea8df6e8a4c (patch)
tree932ac4bf61bf50e484bb2c345899a275d39591d1 /test/dm/acpi.c
parent469f04e8827d6b470ffb0aedf456fa118b2df238 (diff)
downloadu-boot-105da6251a16cfc5db1ef374b5a18ea8df6e8a4c.tar.xz
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.c3
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);