* [PATCH] tools/bpftool: Fix uninitialized error
@ 2020-08-13 22:24 Matthew Kenigsberg
0 siblings, 0 replies; only message in thread
From: Matthew Kenigsberg @ 2020-08-13 22:24 UTC (permalink / raw)
To: linux-kernel
Cc: ast, daniel, kafai, songliubraving, yhs, dzickus, Matthew Kenigsberg
Static analyzer showed following the code path at
tools/bpf/bpftool/main.c:308 leads to returning err when uninitialized
if (n_argc < 0)
goto err_close;
Initializing err to -1 fixes the uninitialized return and prevents
having to add a 3rd err = -1 line.
Signed-off-by: Matthew Kenigsberg <mkenigs@redhat.com>
---
tools/bpf/bpftool/main.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c
index 4a191fcbeb82..a60164fe2b72 100644
--- a/tools/bpf/bpftool/main.c
+++ b/tools/bpf/bpftool/main.c
@@ -245,7 +245,7 @@ static int do_batch(int argc, char **argv)
int n_argc;
FILE *fp;
char *cp;
- int err;
+ int err = -1;
int i;
if (argc < 2) {
@@ -289,7 +289,6 @@ static int do_batch(int argc, char **argv)
strlen(contline) == 0) {
p_err("missing continuation line on command %d",
lines);
- err = -1;
goto err_close;
}
@@ -299,7 +298,6 @@ static int do_batch(int argc, char **argv)
if (strlen(buf) + strlen(contline) + 1 > sizeof(buf)) {
p_err("command %d is too long", lines);
- err = -1;
goto err_close;
}
buf[strlen(buf) - 2] = '\0';
--
2.18.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-08-13 22:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-13 22:24 [PATCH] tools/bpftool: Fix uninitialized error Matthew Kenigsberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®