>     selftests/bpf: Fix memory leak in msg_alloc_iov error path
>
>     In msg_alloc_iov(), when calloc() fails for an individual iov_base
>     allocation, the error path frees all previously allocated iov_base
>     entries but fails to free the iov array itself that was allocated
>     with calloc() at the beginning of the function. This results in a
>     memory leak of the iov array.
>
>     Add free(iov) in the unwind_iov error path to ensure proper cleanup
>     of all allocated memory.
>
>     Fixes: 16962b2404ac ("bpf: sockmap, add selftests")
>     Signed-off-by: Malaya Kumar Rout <[email protected]>

Is the Fixes: tag pointing at the right commit?

In 16962b2404ac ("bpf: sockmap, add selftests") the iov allocation lived
inside msg_loop(), and its out_errno error path already freed the iov
array with free(iov).  There was no msg_alloc_iov() helper and no
unwind_iov label at that point.

The leaking unwind_iov path was introduced later, when the allocation was
refactored into the new msg_alloc_iov() helper whose unwind_iov label
frees each iov_base entry but omits free(iov).  Would this be a better
match?

  Fixes: 753fb2ee0934 ("bpf: sockmap, add msg_peek tests to test_sockmap")


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/28704662518

Reply via email to