From: Puranjay Mohan <puranjay@kernel.org>
To: bot+bpf-ci@kernel.org, eddyz87@gmail.com, bpf@vger.kernel.org,
ast@kernel.org
Cc: andrii@kernel.org, daniel@iogearbox.net, martin.lau@linux.dev,
kernel-team@fb.com, yonghong.song@linux.dev, eddyz87@gmail.com,
cupertino.miranda@oracle.com, ast@kernel.org, andrii@kernel.org,
daniel@iogearbox.net, martin.lau@kernel.org, eddyz87@gmail.com,
yonghong.song@linux.dev, clm@meta.com, ihor.solodrai@linux.dev,
Puranjay Mohan <puranjay12@gmail.com>
Subject: Re: [PATCH bpf-next v2 3/4] selftests/bpf: impose global ordering for test decl_tags
Date: Tue, 31 Mar 2026 14:02:13 +0100 [thread overview]
Message-ID: <m2mrzo17ai.fsf@kernel.org> (raw)
In-Reply-To: <fdf52b7b106f1747fc2e4bf11fa34b28f140b5abb1c698c6800ad167130c10b6@mail.kernel.org>
bot+bpf-ci@kernel.org writes:
>> diff --git a/tools/testing/selftests/bpf/test_loader.c b/tools/testing/selftests/bpf/test_loader.c
>> index 50ca1b6ec8150..3f784cc76f8f5 100644
>> --- a/tools/testing/selftests/bpf/test_loader.c
>> +++ b/tools/testing/selftests/bpf/test_loader.c
>
> [ ... ]
>
>> +static const char **collect_decl_tags(struct btf *btf, int id, int *cnt)
>> +{
>> + const char **tmp, **tags = NULL;
>> + const struct btf_type *t;
>> + int i;
>> +
>> + *cnt = 0;
>> + for (i = 1; i < btf__type_cnt(btf); i++) {
>> + t = btf__type_by_id(btf, i);
>> + if (!btf_is_decl_tag(t) || t->type != id || btf_decl_tag(t)->component_idx != -1)
>> + continue;
>> + tmp = realloc(tags, (*cnt + 1) * sizeof(*tags));
>> + if (!tmp) {
>> + free(tmp);
>> + return ERR_PTR(-ENOMEM);
>> + }
>
> Should free(tmp) be free(tags) here? When realloc fails, tmp is NULL,
> so free(tmp) is a no-op. The previously allocated tags array would be
> leaked.
>
This is correct, realloc() will return NULL on failure, we should do free(tags)
next prev parent reply other threads:[~2026-03-31 13:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 0:59 [PATCH bpf-next v2 0/4] selftests/bpf: impose global ordering for test decl_tags Eduard Zingerman
2026-03-31 0:59 ` [PATCH bpf-next v2 1/4] selftests/bpf: fix __jited_unpriv tag name Eduard Zingerman
2026-03-31 0:59 ` [PATCH bpf-next v2 2/4] selftests/bpf: make str_has_pfx return pointer past the prefix Eduard Zingerman
2026-03-31 12:07 ` Mykyta Yatsenko
2026-03-31 17:52 ` Eduard Zingerman
2026-03-31 0:59 ` [PATCH bpf-next v2 3/4] selftests/bpf: impose global ordering for test decl_tags Eduard Zingerman
2026-03-31 2:38 ` bot+bpf-ci
2026-03-31 13:02 ` Puranjay Mohan [this message]
2026-03-31 17:52 ` Eduard Zingerman
2026-03-31 0:59 ` [PATCH bpf-next v2 4/4] selftests/bpf: inline TEST_TAG constants in test_loader.c Eduard Zingerman
2026-03-31 13:03 ` [PATCH bpf-next v2 0/4] selftests/bpf: impose global ordering for test decl_tags Puranjay Mohan
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=m2mrzo17ai.fsf@kernel.org \
--to=puranjay@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bot+bpf-ci@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clm@meta.com \
--cc=cupertino.miranda@oracle.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
--cc=martin.lau@linux.dev \
--cc=puranjay12@gmail.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