summaryrefslogtreecommitdiff
path: root/test/dm/devres.c
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2020-07-17 00:20:14 +0200
committerSimon Glass <sjg@chromium.org>2020-07-20 11:37:47 -0600
commit105da6251a16cfc5db1ef374b5a18ea8df6e8a4c (patch)
tree932ac4bf61bf50e484bb2c345899a275d39591d1 /test/dm/devres.c
parent469f04e8827d6b470ffb0aedf456fa118b2df238 (diff)
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/devres.c')
-rw-r--r--test/dm/devres.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/test/dm/devres.c b/test/dm/devres.c
index b5de0cb191a..550787495dc 100644
--- a/test/dm/devres.c
+++ b/test/dm/devres.c
@@ -153,6 +153,7 @@ static int dm_test_devres_phase(struct unit_test_state *uts)
* allocation created in the bind() method.
*/
ut_assertok(uclass_find_first_device(UCLASS_TEST_DEVRES, &dev));
+ ut_assertnonnull(dev);
devres_get_stats(dev, &stats);
ut_asserteq(1, stats.allocs);
ut_asserteq(TEST_DEVRES_SIZE, stats.total_size);