On 11 Aug 2025, at 3:52, Baolin Wang wrote:

> On 2025/8/9 03:01, Zi Yan wrote:
>> The helper gathers an folio order statistics of folios within a virtual
>> address range and checks it against a given order list. It aims to provide
>> a more precise folio order check instead of just checking the existence of
>> PMD folios.
>>
>> Signed-off-by: Zi Yan <z...@nvidia.com>
>> ---
>>   .../selftests/mm/split_huge_page_test.c       |   4 +-
>>   tools/testing/selftests/mm/vm_util.c          | 133 ++++++++++++++++++
>>   tools/testing/selftests/mm/vm_util.h          |   7 +
>>   3 files changed, 141 insertions(+), 3 deletions(-)
>>
>
> [snip]
>
>> +
>> +int check_folio_orders(char *vaddr_start, size_t len, int pagemap_file,
>> +                    int kpageflags_file, int orders[], int nr_orders)
>> +{
>> +    int *vaddr_orders;
>> +    int status;
>> +    int i;
>> +
>> +    vaddr_orders = (int *)malloc(sizeof(int) * nr_orders);
>> +
>> +    if (!vaddr_orders)
>> +            ksft_exit_fail_msg("Cannot allocate memory for vaddr_orders");
>> +
>> +    memset(vaddr_orders, 0, sizeof(int) * nr_orders);
>> +    status = gather_folio_orders(vaddr_start, len, pagemap_file,
>> +                                 kpageflags_file, vaddr_orders, nr_orders);
>> +    if (status)
>
> Missed calling free(vaddr_orders) before returning.
>
>> +            return status;
>> +
>> +    status = 0;
>> +    for (i = 0; i < nr_orders; i++)
>> +            if (vaddr_orders[i] != orders[i]) {
>> +                    ksft_print_msg("order %d: expected: %d got %d\n", i,
>> +                                   orders[i], vaddr_orders[i]);
>> +                    status = -1;
>> +            }
>> +
>
> Ditto.
>
>> +    return status;
>> +}
>> +

Will add free() in the above two locations. Thank you for spotting them.

Best Regards,
Yan, Zi

Reply via email to