Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: Feng Yang <yangfeng59949@163.com>
Cc: andrii@kernel.org, eddyz87@gmail.com, ast@kernel.org,
	 daniel@iogearbox.net, memxor@gmail.com, martin.lau@linux.dev,
	song@kernel.org,  yonghong.song@linux.dev, jolsa@kernel.org,
	emil@etsalapatis.com, bpf@vger.kernel.org,
	 linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next] selftests/bpf: Fix memory leak in msg_alloc_iov
Date: Tue, 7 Jul 2026 07:25:56 -0700	[thread overview]
Message-ID: <ak0MRJD7nsf9BaWM@john-p8> (raw)
In-Reply-To: <20260707081434.539327-1-yangfeng59949@163.com>

On Tue, Jul 07, 2026 at 04:14:34PM +0800, Feng Yang wrote:
>From: Feng Yang <yangfeng@kylinos.cn>
>
>In the msg_alloc_iov function, the iov pointer is only assigned to
>msg->msg_iov after all memory allocations complete successfully.
>Therefore, when a calloc failure triggers the unwind_iov cleanup branch,
>we should use the local variable iov instead of msg->msg_iov.
>
>Fixes: 753fb2ee0934 ("bpf: sockmap, add msg_peek tests to test_sockmap")
>Signed-off-by: Feng Yang <yangfeng@kylinos.cn>
>---
> tools/testing/selftests/bpf/test_sockmap.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c
>index 3e6be455d158..aaf2050e8845 100644
>--- a/tools/testing/selftests/bpf/test_sockmap.c
>+++ b/tools/testing/selftests/bpf/test_sockmap.c
>@@ -435,7 +435,7 @@ static int msg_alloc_iov(struct msghdr *msg,
> 	return 0;
> unwind_iov:
> 	for (i--; i >= 0 ; i--)
>-		free(msg->msg_iov[i].iov_base);
>+		free(iov[i].iov_base);
> 	free(iov);
> 	return -ENOMEM;

Thanks,

Reviewed-by: John Fastabend <john.fastabend@gmail.com>

  reply	other threads:[~2026-07-07 14:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07  8:14 [PATCH bpf-next] selftests/bpf: Fix memory leak in msg_alloc_iov Feng Yang
2026-07-07 14:25 ` John Fastabend [this message]
2026-07-07 18: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=ak0MRJD7nsf9BaWM@john-p8 \
    --to=john.fastabend@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=song@kernel.org \
    --cc=yangfeng59949@163.com \
    --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