]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
bpf: fix uninitialized variable in bpf tools
authorJohn Fastabend <john.fastabend@gmail.com>
Wed, 25 Apr 2018 22:08:53 +0000 (15:08 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 1 Oct 2018 12:55:51 +0000 (14:55 +0200)
commit8a66565a6ed3edc758cf08f01882683ea5e72ec8
tree68d8c6a52287d8939aacb8051148ec52bd435145
parent37f3d249ef358a5b8aadd63b0a7a34724f676c63
bpf: fix uninitialized variable in bpf tools

BugLink: http://bugs.launchpad.net/bugs/1794889
[ Upstream commit 815425567dea6c54494e85050631d6bdda907c5d ]

Here the variable cont is used as the saved_pointer for a call to
strtok_r(). It is safe to use the value uninitialized in this
context however and the later reference is only ever used if
the strtok_r is successful. But, 'gcc-5' at least doesn't have all
this knowledge so initialize cont to NULL. Additionally, do the
natural NULL check before accessing just for completness.

The warning is the following:

./bpf/tools/bpf/bpf_dbg.c: In function ‘cmd_load’:
./bpf/tools/bpf/bpf_dbg.c:1077:13: warning: ‘cont’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  } else if (matches(subcmd, "pcap") == 0) {

Fixes: fd981e3c321a "filter: bpf_dbg: add minimal bpf debugger"
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
tools/bpf/bpf_dbg.c