Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The newly introduced error path returns -1 to prevent an OOM crash, but this does not coordinate with the Python test harnesses to actually skip the test or report a resource error. Instead, it causes tests to either silently pass (false positive) or crash with Python exceptions.
--
--- Patch [1]: [PATCH v2] selftests/damon: Add missing NULL checks after malloc() ---
commit c48bfd12db1afa969a2ab38d496264e74f1b6b1e
Author: longlong yan <[email protected]>
selftests/damon: Add missing NULL checks after malloc()
This commit adds NULL checks after malloc() calls in access_memory.c and
access_memory_even.c to prevent crashes during low-memory conditions.
> diff --git a/tools/testing/selftests/damon/access_memory.c b/tools/testing/selftests/damon/access_memory.c
> --- a/tools/testing/selftests/damon/access_memory.c
> +++ b/tools/testing/selftests/damon/access_memory.c
> @@ -38,8 +38,17 @@ int main(int argc, char *argv[])
> mode = ACCESS_MODE_REPEAT;
>
> regions = malloc(sizeof(*regions) * nr_regions);
> - for (i = 0; i < nr_regions; i++)
> + if (!regions) {
> + fprintf(stderr, "Failed to allocate regions array\n");
> + return -1;
[Severity: Medium]
Will returning -1 here coordinate correctly with the Python test harnesses
like damos_quota.py and sysfs_update_schemes_tried_regions_wss_estimation.py?
If the Python scripts do not check the subprocess return code, an early exit
might leave data arrays empty. Depending on the script, this can either lead
to a Python IndexError (e.g., when accessing wss_collected in
pass_wss_estimation) or a silent test pass that masks the out of memory
condition entirely.
Should this return KSFT_SKIP (4) instead to properly notify the test harness,
or do the Python scripts need updating to verify the return code?
> + }
> + for (i = 0; i < nr_regions; i++) {
> regions[i] = malloc(sz_region);
> + if (!regions[i]) {
> + fprintf(stderr, "Failed to allocate region %d\n", i);
> + return -1;
> + }
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.