forked from OERV-BSP/u-boot
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>
This commit is contained in:
committed by
Simon Glass
parent
469f04e882
commit
105da6251a
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user