* [PATCH v1] afpacket: fix critical issue reported by klocwork @ 2015-02-12 9:08 Cunming Liang [not found] ` <1423732089-6202-1-git-send-email-cunming.liang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: Cunming Liang @ 2015-02-12 9:08 UTC (permalink / raw) To: dev-VfR2kkLFssw Klocwork report 'req' might be used uninitialized. In some cases it can 'goto error' when '*internals' not been set. The result is unexpected checking the value of '*internals'. Signed-off-by: Cunming Liang <cunming.liang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> --- lib/librte_pmd_af_packet/rte_eth_af_packet.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c b/lib/librte_pmd_af_packet/rte_eth_af_packet.c index 1ffe1cd..185607d 100644 --- 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; struct pkt_rx_queue *rx_queue; struct pkt_tx_queue *tx_queue; int rc, qsockfd, tpver, discard; unsigned int i, q, rdsize; int fanout_arg __rte_unused, bypass __rte_unused; + *internals = NULL; + for (k_idx = 0; k_idx < kvlist->count; k_idx++) { pair = &kvlist->pairs[k_idx]; if (strstr(pair->key, ETH_AF_PACKET_IFACE_ARG) != NULL) -- 1.8.1.4 ^ permalink raw reply related [flat|nested] 7+ messages in thread
[parent not found: <1423732089-6202-1-git-send-email-cunming.liang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v1] afpacket: fix critical issue reported by klocwork [not found] ` <1423732089-6202-1-git-send-email-cunming.liang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> @ 2015-02-20 10:19 ` Thomas Monjalon 2015-02-20 18:38 ` John W. Linville 0 siblings, 1 reply; 7+ messages in thread From: Thomas Monjalon @ 2015-02-20 10:19 UTC (permalink / raw) To: Cunming Liang; +Cc: dev-VfR2kkLFssw, John Linville Hi Cunming, You would have more chance to have a review by CC'ing John. I checked your patch and have a comment below. 2015-02-12 17:08, Cunming Liang: > Klocwork report 'req' might be used uninitialized. > In some cases it can 'goto error' when '*internals' not been set. > The result is unexpected checking the value of '*internals'. > > Signed-off-by: Cunming Liang <cunming.liang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > --- > lib/librte_pmd_af_packet/rte_eth_af_packet.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c b/lib/librte_pmd_af_packet/rte_eth_af_packet.c > index 1ffe1cd..185607d 100644 > --- 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. > struct pkt_rx_queue *rx_queue; > struct pkt_tx_queue *tx_queue; > int rc, qsockfd, tpver, discard; > unsigned int i, q, rdsize; > int fanout_arg __rte_unused, bypass __rte_unused; > > + *internals = NULL; > + > for (k_idx = 0; k_idx < kvlist->count; k_idx++) { > pair = &kvlist->pairs[k_idx]; > if (strstr(pair->key, ETH_AF_PACKET_IFACE_ARG) != NULL) > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1] afpacket: fix critical issue reported by klocwork 2015-02-20 10:19 ` Thomas Monjalon @ 2015-02-20 18:38 ` John W. Linville [not found] ` <20150220183854.GA4179-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: John W. Linville @ 2015-02-20 18:38 UTC (permalink / raw) To: Thomas Monjalon; +Cc: dev-VfR2kkLFssw, John Linville On Fri, Feb 20, 2015 at 11:19:59AM +0100, Thomas Monjalon wrote: > Hi Cunming, > > You would have more chance to have a review by CC'ing John. > I checked your patch and have a comment below. > > 2015-02-12 17:08, Cunming Liang: > > Klocwork report 'req' might be used uninitialized. > > In some cases it can 'goto error' when '*internals' not been set. > > The result is unexpected checking the value of '*internals'. > > > > Signed-off-by: Cunming Liang <cunming.liang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > > --- > > lib/librte_pmd_af_packet/rte_eth_af_packet.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c b/lib/librte_pmd_af_packet/rte_eth_af_packet.c > > index 1ffe1cd..185607d 100644 > > --- 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. I agree -- it looks to me like req is protected by checking for *internals == NULL. I don't think this patch is necessary. > > struct pkt_rx_queue *rx_queue; > > struct pkt_tx_queue *tx_queue; > > int rc, qsockfd, tpver, discard; > > unsigned int i, q, rdsize; > > int fanout_arg __rte_unused, bypass __rte_unused; > > > > + *internals = NULL; > > + > > for (k_idx = 0; k_idx < kvlist->count; k_idx++) { > > pair = &kvlist->pairs[k_idx]; > > if (strstr(pair->key, ETH_AF_PACKET_IFACE_ARG) != NULL) > > > > > > -- John W. Linville Someday the world will need a hero, and you linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org might be all we have. Be ready. ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <20150220183854.GA4179-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>]
* Re: [PATCH v1] afpacket: fix critical issue reported by klocwork [not found] ` <20150220183854.GA4179-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org> @ 2015-02-25 0:57 ` Liang, Cunming [not found] ` <D0158A423229094DA7ABF71CF2FA0DA3118DE679-E2R4CRU6q/6iAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: Liang, Cunming @ 2015-02-25 0:57 UTC (permalink / raw) To: John W. Linville, Thomas Monjalon Cc: dev-VfR2kkLFssw@public.gmane.org, John Linville > -----Original Message----- > From: John W. Linville [mailto:linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org] > Sent: Saturday, February 21, 2015 2:39 AM > To: Thomas Monjalon > Cc: Liang, Cunming; dev-VfR2kkLFssw@public.gmane.org; John Linville > Subject: Re: [dpdk-dev] [PATCH v1] afpacket: fix critical issue reported by > klocwork > > On Fri, Feb 20, 2015 at 11:19:59AM +0100, Thomas Monjalon wrote: > > Hi Cunming, > > > > You would have more chance to have a review by CC'ing John. > > I checked your patch and have a comment below. > > > > 2015-02-12 17:08, Cunming Liang: > > > Klocwork report 'req' might be used uninitialized. > > > In some cases it can 'goto error' when '*internals' not been set. > > > The result is unexpected checking the value of '*internals'. > > > > > > Signed-off-by: Cunming Liang <cunming.liang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> > > > --- > > > lib/librte_pmd_af_packet/rte_eth_af_packet.c | 4 +++- > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c > b/lib/librte_pmd_af_packet/rte_eth_af_packet.c > > > index 1ffe1cd..185607d 100644 > > > --- 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;'. > > > > struct pkt_rx_queue *rx_queue; > > > struct pkt_tx_queue *tx_queue; > > > int rc, qsockfd, tpver, discard; > > > unsigned int i, q, rdsize; > > > int fanout_arg __rte_unused, bypass __rte_unused; > > > > > > + *internals = NULL; > > > + > > > for (k_idx = 0; k_idx < kvlist->count; k_idx++) { > > > pair = &kvlist->pairs[k_idx]; > > > if (strstr(pair->key, ETH_AF_PACKET_IFACE_ARG) != NULL) > > > > > > > > > > > > > -- > John W. Linville Someday the world will need a hero, and you > linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org might be all we have. Be ready. ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <D0158A423229094DA7ABF71CF2FA0DA3118DE679-E2R4CRU6q/6iAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org>]
* Re: [PATCH v1] afpacket: fix critical issue reported by klocwork [not found] ` <D0158A423229094DA7ABF71CF2FA0DA3118DE679-E2R4CRU6q/6iAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org> @ 2015-02-25 8:45 ` Thomas Monjalon 2015-02-25 9:52 ` Liang, Cunming 0 siblings, 1 reply; 7+ messages in thread From: Thomas Monjalon @ 2015-02-25 8:45 UTC (permalink / raw) To: Liang, Cunming; +Cc: dev-VfR2kkLFssw, John Linville 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1] afpacket: fix critical issue reported by klocwork 2015-02-25 8:45 ` Thomas Monjalon @ 2015-02-25 9:52 ` Liang, Cunming [not found] ` <D0158A423229094DA7ABF71CF2FA0DA3118DED48-E2R4CRU6q/6iAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org> 0 siblings, 1 reply; 7+ messages in thread From: Liang, Cunming @ 2015-02-25 9:52 UTC (permalink / raw) To: Thomas Monjalon; +Cc: dev-VfR2kkLFssw@public.gmane.org, John Linville > -----Original Message----- > From: Thomas Monjalon [mailto:thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org] > Sent: Wednesday, February 25, 2015 4:46 PM > To: Liang, Cunming > Cc: John W. Linville; dev-VfR2kkLFssw@public.gmane.org; John Linville > Subject: Re: [dpdk-dev] [PATCH v1] afpacket: fix critical issue reported by > klocwork > > 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 ? ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <D0158A423229094DA7ABF71CF2FA0DA3118DED48-E2R4CRU6q/6iAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org>]
* Re: [PATCH v1] afpacket: fix critical issue reported by klocwork [not found] ` <D0158A423229094DA7ABF71CF2FA0DA3118DED48-E2R4CRU6q/6iAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org> @ 2015-02-25 9:56 ` Thomas Monjalon 0 siblings, 0 replies; 7+ messages in thread From: Thomas Monjalon @ 2015-02-25 9:56 UTC (permalink / raw) To: Liang, Cunming; +Cc: dev-VfR2kkLFssw, John Linville 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. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-02-25 9:56 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-02-12 9:08 [PATCH v1] afpacket: fix critical issue reported by klocwork Cunming Liang [not found] ` <1423732089-6202-1-git-send-email-cunming.liang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> 2015-02-20 10:19 ` Thomas Monjalon 2015-02-20 18:38 ` John W. Linville [not found] ` <20150220183854.GA4179-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org> 2015-02-25 0:57 ` Liang, Cunming [not found] ` <D0158A423229094DA7ABF71CF2FA0DA3118DE679-E2R4CRU6q/6iAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org> 2015-02-25 8:45 ` Thomas Monjalon 2015-02-25 9:52 ` Liang, Cunming [not found] ` <D0158A423229094DA7ABF71CF2FA0DA3118DED48-E2R4CRU6q/6iAffOGbnezLfspsVTdybXVpNB7YpNyf8@public.gmane.org> 2015-02-25 9:56 ` Thomas Monjalon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).