mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Kenigsberg <mkenigs@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, kafai@fb.com,
	songliubraving@fb.com, yhs@fb.com, dzickus@redhat.com,
	Matthew Kenigsberg <mkenigs@redhat.com>
Subject: [PATCH] tools/bpftool: Fix uninitialized error
Date: Thu, 13 Aug 2020 16:24:31 -0600	[thread overview]
Message-ID: <20200813222431.25884-1-mkenigs@redhat.com> (raw)

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


                 reply	other threads:[~2020-08-13 22:25 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=20200813222431.25884-1-mkenigs@redhat.com \
    --to=mkenigs@redhat.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dzickus@redhat.com \
    --cc=kafai@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /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

all inboxes | Powered by JetHome®