From: "Emil Tsalapatis" <emil@etsalapatis.com>
To: "Malaya Kumar Rout" <malayarout91@gmail.com>, <andrii@kernel.org>,
<daniel@iogearbox.net>, <martin.lau@linux.dev>
Cc: "Alexei Starovoitov" <ast@kernel.org>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Shuah Khan" <shuah@kernel.org>,
"John Fastabend" <john.fastabend@gmail.com>,
<bpf@vger.kernel.org>, <linux-kselftest@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] selftests/bpf: Fix memory leak in msg_alloc_iov error path
Date: Mon, 06 Jul 2026 12:04:04 -0400 [thread overview]
Message-ID: <DJRM6DY3TW3X.1OJSVM8VW21B4@etsalapatis.com> (raw)
In-Reply-To: <20260704122936.102394-1-malayarout91@gmail.com>
On Sat Jul 4, 2026 at 8:29 AM EDT, Malaya Kumar Rout wrote:
> 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: 753fb2ee0934 ("bpf: sockmap, add msg_peek tests to test_sockmap")
> Signed-off-by: Malaya Kumar Rout <malayarout91@gmail.com>
Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
> ---
> tools/testing/selftests/bpf/test_sockmap.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c
> index ac814eb63edb..3e6be455d158 100644
> --- a/tools/testing/selftests/bpf/test_sockmap.c
> +++ b/tools/testing/selftests/bpf/test_sockmap.c
> @@ -436,6 +436,7 @@ static int msg_alloc_iov(struct msghdr *msg,
> unwind_iov:
> for (i--; i >= 0 ; i--)
> free(msg->msg_iov[i].iov_base);
> + free(iov);
> return -ENOMEM;
> }
>
next prev parent reply other threads:[~2026-07-06 16:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-04 11:10 [PATCH] selftests/bpf: Fix memory leak in msg_alloc_iov error path Malaya Kumar Rout
2026-07-04 11:47 ` bot+bpf-ci
2026-07-04 12:29 ` [PATCH v2] " Malaya Kumar Rout
2026-07-06 16:04 ` Emil Tsalapatis [this message]
2026-07-06 19:30 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DJRM6DY3TW3X.1OJSVM8VW21B4@etsalapatis.com \
--to=emil@etsalapatis.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=malayarout91@gmail.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox