From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH v1] afpacket: fix critical issue reported by klocwork Date: Wed, 25 Feb 2015 10:56:22 +0100 Message-ID: <1918339.MLD1NqnMmG@xps13> References: <1423732089-6202-1-git-send-email-cunming.liang@intel.com> <1514821.oaVEE2NRMm@xps13> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev-VfR2kkLFssw@public.gmane.org, John Linville To: "Liang, Cunming" Return-path: In-Reply-To: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 2015-02-25 09:52, Liang, Cunming: > From: Thomas Monjalon [mailto:thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org] > > 2015-02-25 00:57, Liang, Cunming: > > > From: John W. Linville [mailto:linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org] > > > > On Fri, Feb 20, 2015 at 11:19:59AM +0100, Thomas Monjalon wrote: > > > > > 2015-02-12 17:08, Cunming Liang: > > > > > > --- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c > > > > > > +++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c > > > > > > @@ -439,13 +439,15 @@ rte_pmd_init_internals(const char *name, > > > > > > size_t ifnamelen; > > > > > > unsigned k_idx; > > > > > > struct sockaddr_ll sockaddr; > > > > > > - struct tpacket_req *req; > > > > > > + struct tpacket_req *req = NULL; > > > > > > > > > > If *internals is set to NULL, there should be no case where req used > > > > > and undefined. > > > > > > [LCM] Agree, so that's why I add '*internals = NULL' below as well. > > > > > > > > I agree -- it looks to me like req is protected by checking for > > > > *internals == NULL. I don't think this patch is necessary. > > > > > > [LCM] The major piece of the patch is add setting for '*internals=NULL;'. > > > > Yes understood, but it is already initialized to NULL before calling > > rte_pmd_init_internals(): > > http://dpdk.org/browse/dpdk/tree/lib/librte_pmd_af_packet/rte_eth_af_packet > > .c#n706 > [LCM] I see, it's complained by klocwork. > So either adding 'internals=NULL' or adding some comments helps to avoid checking again on the next scanning. > How do you think ? No, we don't have to pollute the code for a tool. You should check how to disable this false positive in your tool.