[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20200813222431.25884-1-mkenigs@redhat.com>
Date: Thu, 13 Aug 2020 16:24:31 -0600
From: Matthew Kenigsberg <mkenigs@...hat.com>
To: linux-kernel@...r.kernel.org
Cc: ast@...nel.org, daniel@...earbox.net, kafai@...com,
songliubraving@...com, yhs@...com, dzickus@...hat.com,
Matthew Kenigsberg <mkenigs@...hat.com>
Subject: [PATCH] tools/bpftool: Fix uninitialized error
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@...hat.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
Powered by blists - more mailing lists