All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] selftests: cgroup: add memory controller self-tests
@ 2019-03-27  7:32 ` Dan Carpenter
  0 siblings, 0 replies; 16+ messages in thread
From: dan.carpenter @ 2019-03-27  7:32 UTC (permalink / raw)


Hello Roman Gushchin,

The patch 84092dbcf901: "selftests: cgroup: add memory controller
self-tests" from May 11, 2018, leads to the following static checker
warning:

	./tools/testing/selftests/cgroup/test_memcontrol.c:77 test_memcg_subtree_control()
	error: uninitialized symbol 'child2'.

./tools/testing/selftests/cgroup/test_memcontrol.c
    27 static int test_memcg_subtree_control(const char *root)
    28 {
    29 	char *parent, *child, *parent2, *child2;
                               ^^^^^^^^^^^^^^^^
    30 	int ret = KSFT_FAIL;
    31 	char buf[PAGE_SIZE];
    32 
    33 	/* Create two nested cgroups with the memory controller enabled */
    34 	parent = cg_name(root, "memcg_test_0");
    35 	child = cg_name(root, "memcg_test_0/memcg_test_1");
    36 	if (!parent || !child)
    37 		goto cleanup;
                ^^^^^^^^^^^^

    38 
    39 	if (cg_create(parent))
    40 		goto cleanup;
    41 
    42 	if (cg_write(parent, "cgroup.subtree_control", "+memory"))
    43 		goto cleanup;
    44 
    45 	if (cg_create(child))
    46 		goto cleanup;
    47 
    48 	if (cg_read_strstr(child, "cgroup.controllers", "memory"))
    49 		goto cleanup;
    50 
    51 	/* Create two nested cgroups without enabling memory controller */
    52 	parent2 = cg_name(root, "memcg_test_1");
    53 	child2 = cg_name(root, "memcg_test_1/memcg_test_1");
    54 	if (!parent2 || !child2)
    55 		goto cleanup;
    56 
    57 	if (cg_create(parent2))
    58 		goto cleanup;
    59 
    60 	if (cg_create(child2))
    61 		goto cleanup;
    62 
    63 	if (cg_read(child2, "cgroup.controllers", buf, sizeof(buf)))
    64 		goto cleanup;
    65 
    66 	if (!cg_read_strstr(child2, "cgroup.controllers", "memory"))
    67 		goto cleanup;
    68 
    69 	ret = KSFT_PASS;
    70 
    71 cleanup:
    72 	cg_destroy(child);
    73 	cg_destroy(parent);
    74 	free(parent);
    75 	free(child);
    76 
--> 77 	cg_destroy(child2);
        ^^^^^^^^^^^^^^^^^
    78 	cg_destroy(parent2);
        ^^^^^^^^^^^^^^^^^^
    79 	free(parent2);
    80 	free(child2);
    81 
    82 	return ret;
    83 }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [bug report] selftests: cgroup: add memory controller self-tests
@ 2018-06-26  9:03 ` Dan Carpenter
  0 siblings, 0 replies; 16+ messages in thread
From: dan.carpenter @ 2018-06-26  9:03 UTC (permalink / raw)


Hello Roman Gushchin,

The patch 84092dbcf901: "selftests: cgroup: add memory controller
self-tests" from May 11, 2018, leads to the following static checker
warning:

	./tools/testing/selftests/cgroup/test_memcontrol.c:76 test_memcg_subtree_control()
	error: uninitialized symbol 'child2'.

./tools/testing/selftests/cgroup/test_memcontrol.c
    69  
    70  cleanup:
    71          cg_destroy(child);
    72          cg_destroy(parent);
    73          free(parent);
    74          free(child);
    75  
    76          cg_destroy(child2);

The problem with using one error label to handle all possible returns
is that some stuff hasn't been initialized yet.

    77          cg_destroy(parent2);
    78          free(parent2);
    79          free(child2);
    80  
    81          return ret;
    82  }

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [bug report] selftests: cgroup: add memory controller self-tests
@ 2018-05-17 13:22 ` Dan Carpenter
  0 siblings, 0 replies; 16+ messages in thread
From: dan.carpenter @ 2018-05-17 13:22 UTC (permalink / raw)


Hello Roman Gushchin,

The patch a62213fe9b77: "selftests: cgroup: add memory controller
self-tests" from May 11, 2018, leads to the following static checker
warning:

	./tools/testing/selftests/cgroup/cgroup_util.c:62 cg_name()
	warn: variable dereferenced before check 'name' (see line 59)

./tools/testing/selftests/cgroup/cgroup_util.c
    57  char *cg_name(const char *root, const char *name)
    58  {
    59          size_t len = strlen(root) + strlen(name) + 2;
                                            ^^^^^^^^^^^^
    60          char *ret = malloc(len);
    61  
    62          if (name)
                    ^^^^
    63                  snprintf(ret, len, "%s/%s", root, name);
    64  
    65          return ret;
    66  }
    67  
    68  char *cg_name_indexed(const char *root, const char *name, int index)
    69  {
    70          size_t len = strlen(root) + strlen(name) + 10;
                                            ^^^^^^^^^^^^
    71          char *ret = malloc(len);
    72  
    73          if (name)
                    ^^^^
    74                  snprintf(ret, len, "%s/%s_%d", root, name, index);
    75  
    76          return ret;
    77  }

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-03-28  2:58 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-27  7:32 [bug report] selftests: cgroup: add memory controller self-tests dan.carpenter
2019-03-27  7:32 ` Dan Carpenter
2019-03-27 22:24 ` guro
2019-03-27 22:24   ` Roman Gushchin
2019-03-27 22:50   ` shuah
2019-03-27 22:50     ` shuah
2019-03-28  2:58     ` guro
2019-03-28  2:58       ` Roman Gushchin
  -- strict thread matches above, loose matches on Subject: below --
2018-06-26  9:03 dan.carpenter
2018-06-26  9:03 ` Dan Carpenter
2018-06-26 17:15 ` guro
2018-06-26 17:15   ` Roman Gushchin
2018-05-17 13:22 dan.carpenter
2018-05-17 13:22 ` Dan Carpenter
2018-05-17 15:56 ` guro
2018-05-17 15:56   ` Roman Gushchin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.