From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
To: bpf@vger.kernel.org
Cc: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Subject: [PATCH] samples: bpf: Fix uninitialized variable in xdp_redirect_cpu
Date: Thu, 26 Aug 2021 17:39:10 +0530 [thread overview]
Message-ID: <20210826120910.454081-1-memxor@gmail.com> (raw)
While at it, also improve help output when CPU number is greater than
possible.
Fixes: e531a220cc59 ("samples: bpf: Convert xdp_redirect_cpu to XDP samples helper")
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
samples/bpf/xdp_redirect_cpu_user.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/samples/bpf/xdp_redirect_cpu_user.c b/samples/bpf/xdp_redirect_cpu_user.c
index 631700aef69c..6e25fba64c72 100644
--- a/samples/bpf/xdp_redirect_cpu_user.c
+++ b/samples/bpf/xdp_redirect_cpu_user.c
@@ -141,7 +141,7 @@ static int create_cpu_entry(__u32 cpu, struct bpf_cpumap_val *value,
static int mark_cpus_unavailable(void)
{
int ret, i, n_cpus = libbpf_num_possible_cpus();
- __u32 invalid_cpu;
+ __u32 invalid_cpu = n_cpus;
for (i = 0; i < n_cpus; i++) {
ret = bpf_map_update_elem(avail_fd, &i,
@@ -449,8 +449,9 @@ int main(int argc, char **argv)
add_cpu = strtoul(optarg, NULL, 0);
if (add_cpu >= n_cpus) {
fprintf(stderr,
- "--cpu nr too large for cpumap err(%d):%s\n",
+ "--cpu nr too large for cpumap err (%d):%s\n",
errno, strerror(errno));
+ usage(argv, long_options, __doc__, mask, true, skel->obj);
goto end_cpu;
}
cpu[added_cpus++] = add_cpu;
--
2.33.0
reply other threads:[~2021-08-26 12:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210826120910.454081-1-memxor@gmail.com \
--to=memxor@gmail.com \
--cc=bpf@vger.kernel.org \
/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