mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-12-10 20:11:36 +01:00
test: dm: devres: Remove use-after-free
Use-after-free shouldn't be used, even in tests. It's bad practice and makes the test brittle. Signed-off-by: Andrew Scull <ascull@google.com> Cc: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
7f58feae3f
commit
d69616e529
@ -178,11 +178,8 @@ static int dm_test_devres_phase(struct unit_test_state *uts)
|
|||||||
ut_asserteq(1, stats.allocs);
|
ut_asserteq(1, stats.allocs);
|
||||||
ut_asserteq(TEST_DEVRES_SIZE, stats.total_size);
|
ut_asserteq(TEST_DEVRES_SIZE, stats.total_size);
|
||||||
|
|
||||||
/* Unbinding removes the other. Note this access a freed pointer */
|
/* Unbinding removes the other. */
|
||||||
device_unbind(dev);
|
device_unbind(dev);
|
||||||
devres_get_stats(dev, &stats);
|
|
||||||
ut_asserteq(0, stats.allocs);
|
|
||||||
ut_asserteq(0, stats.total_size);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user