From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Borkmann Subject: Re: [bpf PATCH] bpf: fix uninitialized variable in bpf tools Date: Thu, 26 Apr 2018 22:55:54 +0200 Message-ID: <66dea869-f3e3-355d-928a-8894e672b914@iogearbox.net> References: <20180425220852.10403.79675.stgit@john-Precision-Tower-5810> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: netdev@vger.kernel.org To: John Fastabend , ast@kernel.org, jbenc@redhat.com Return-path: Received: from www62.your-server.de ([213.133.104.62]:44563 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753529AbeDZUz6 (ORCPT ); Thu, 26 Apr 2018 16:55:58 -0400 In-Reply-To: <20180425220852.10403.79675.stgit@john-Precision-Tower-5810> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 04/26/2018 12:08 AM, John Fastabend wrote: > 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 Applied to bpf tree, thanks John!