Date: Sat, 25 Mar 2023 19:11:13 +0100 The label “cleanup” was used to jump to another pointer check despite of the detail in the implementation of the function “test_memcg_oom_group_score_events” that it was determined already that a corresponding variable contained a null pointer. 1. Thus return directly after a call of the function “cg_name” failed. 2. Use an additional label. 3. Delete a questionable check. This issue was detected by using the Coccinelle software. Fixes: a987785dcd6c8ae2915460582aebd6481c81eb67 ("Add tests for memory.oom.group") Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> --- tools/testing/selftests/cgroup/test_memcontrol.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index f4f7c0aef702..afcd1752413e 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -1242,12 +1242,11 @@ static int test_memcg_oom_group_score_events(const char *root) int safe_pid; memcg = cg_name(root, "memcg_test_0"); - if (!memcg) - goto cleanup; + return ret; if (cg_create(memcg)) - goto cleanup; + goto free_cg; if (cg_write(memcg, "memory.max", "50M")) goto cleanup; @@ -1275,8 +1274,8 @@ static int test_memcg_oom_group_score_events(const char *root) ret = KSFT_PASS; cleanup: - if (memcg) - cg_destroy(memcg); + cg_destroy(memcg); +free_cg: free(memcg); return ret; -- 2.40.0