]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: dm: devres: Remove use-after-free
authorAndrew Scull <ascull@google.com>
Sun, 3 Apr 2022 10:39:15 +0000 (10:39 +0000)
committerTom Rini <trini@konsulko.com>
Fri, 29 Apr 2022 15:11:36 +0000 (11:11 -0400)
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>
test/dm/devres.c

index 4f959d11da928cdd75a3a847509636745c7f1480..524114c833c1880c6806ff27218cb4257ce7bf4c 100644 (file)
@@ -178,11 +178,8 @@ static int dm_test_devres_phase(struct unit_test_state *uts)
        ut_asserteq(1, stats.allocs);
        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);
-       devres_get_stats(dev, &stats);
-       ut_asserteq(0, stats.allocs);
-       ut_asserteq(0, stats.total_size);
 
        return 0;
 }