DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Jastrzebski, MichalX K" <michalx.k.jastrzebski@intel.com>
To: "Yigit, Ferruh" <ferruh.yigit@intel.com>,
	"skhare@vmware.com" <skhare@vmware.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	"Jain, Deepak K" <deepak.k.jain@intel.com>,
	 "Kulasek, TomaszX" <tomaszx.kulasek@intel.com>,
	"yongwang@vmware.com" <yongwang@vmware.com>,
	"stable@dpdk.org" <stable@dpdk.org>
Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH] net/vmxnet3: fix dereference before null check
Date: Mon, 25 Sep 2017 09:27:25 +0000	[thread overview]
Message-ID: <60ABE07DBB3A454EB7FAD707B4BB158213C3EB24@IRSMSX109.ger.corp.intel.com> (raw)
In-Reply-To: <0dc033ed-f3e4-2f31-dede-7f5295d92e3c@intel.com>

> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Friday, September 22, 2017 6:39 PM
> To: Jastrzebski, MichalX K <michalx.k.jastrzebski@intel.com>;
> skhare@vmware.com
> Cc: dev@dpdk.org; Jain, Deepak K <deepak.k.jain@intel.com>; Kulasek,
> TomaszX <tomaszx.kulasek@intel.com>; yongwang@vmware.com;
> stable@dpdk.org
> Subject: Re: [dpdk-stable] [PATCH] net/vmxnet3: fix dereference before null
> check
> 
> On 9/22/2017 1:39 PM, Michal Jastrzebski wrote:
> > From: Tomasz Kulasek <tomaszx.kulasek@intel.com>
> >
> > Coverity error:
> >
> > check_after_deref: Null-checking rq suggests that it may be null, but it
> >                    has already been dereferenced on all paths leading to
> >                    the check.
> >
> > This patch moves NULL checking of "rq" at the very beginning of the path
> > before any dereference.
> >
> > Coverity issue: 143468
> > Fixes: 5aecdc17a97d ("vmxnet3: fix stop/restart")
> > Cc: yongwang@vmware.com
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
> > ---
> >  drivers/net/vmxnet3/vmxnet3_rxtx.c | 17 ++++++++---------
> >  1 file changed, 8 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c
> b/drivers/net/vmxnet3/vmxnet3_rxtx.c
> > index d9cf437..4fcceb4 100644
> > --- a/drivers/net/vmxnet3/vmxnet3_rxtx.c
> > +++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c
> > @@ -259,17 +259,16 @@
> >  {
> >  	int i;
> >  	vmxnet3_rx_queue_t *rq = rxq;
> > -	struct vmxnet3_hw *hw = rq->hw;
> >  	struct vmxnet3_cmd_ring *ring0, *ring1;
> >  	struct vmxnet3_comp_ring *comp_ring;
> > -	struct vmxnet3_rx_data_ring *data_ring = &rq->data_ring;
> >  	int size;
> >
> > -	if (rq != NULL) {
> 
> vmxnet3_dev_rx_queue_reset() is static function and only called from
> single function [1], which already checks if the parameter is NULL.
> 
> What do you think just removing this check and keep rest same?
> 
> [1]
> vmxnet3_dev_clear_queues()
> 

Hi Ferruh,
Ok, we can try to do this as You suggest - we will see 
what coverity tells about that in the next build.
As long as vmxnet3_dev_clear_queues() checks if the parameter is NULL,
We can also classify this issue as False/Positive 
if our solution in this iteration doesn't help.

Michal.

> > -		/* Release both the cmd_rings mbufs */
> > -		for (i = 0; i < VMXNET3_RX_CMDRING_SIZE; i++)
> > -			vmxnet3_rx_cmd_ring_release_mbufs(&rq-
> >cmd_ring[i]);
> > -	}
> > +	if (rq == NULL)
> > +		return;
> > +
> > +	/* Release both the cmd_rings mbufs */
> > +	for (i = 0; i < VMXNET3_RX_CMDRING_SIZE; i++)
> > +		vmxnet3_rx_cmd_ring_release_mbufs(&rq->cmd_ring[i]);
> >
> >  	ring0 = &rq->cmd_ring[0];
> >  	ring1 = &rq->cmd_ring[1];
> > @@ -287,8 +286,8 @@
> >
> >  	size = sizeof(struct Vmxnet3_RxDesc) * (ring0->size + ring1->size);
> >  	size += sizeof(struct Vmxnet3_RxCompDesc) * comp_ring->size;
> > -	if (VMXNET3_VERSION_GE_3(hw) && rq->data_desc_size)
> > -		size += rq->data_desc_size * data_ring->size;
> > +	if (VMXNET3_VERSION_GE_3(rq->hw) && rq->data_desc_size)
> > +		size += rq->data_desc_size * rq->data_ring.size;
> >
> >  	memset(ring0->base, 0, size);
> >  }
> >


  reply	other threads:[~2017-09-25  9:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-22 12:39 [dpdk-dev] " Michal Jastrzebski
2017-09-22 16:39 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
2017-09-25  9:27   ` Jastrzebski, MichalX K [this message]
2017-09-25 10:02     ` Ferruh Yigit
2017-09-29 13:04 ` [dpdk-dev] [PATCH v2] " Michal Jastrzebski
2017-10-02 13:58   ` Jastrzebski, MichalX K
2017-10-02 21:39   ` Ferruh Yigit
2017-10-02 21:45     ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit

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=60ABE07DBB3A454EB7FAD707B4BB158213C3EB24@IRSMSX109.ger.corp.intel.com \
    --to=michalx.k.jastrzebski@intel.com \
    --cc=deepak.k.jain@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=skhare@vmware.com \
    --cc=stable@dpdk.org \
    --cc=tomaszx.kulasek@intel.com \
    --cc=yongwang@vmware.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;
as well as URLs for NNTP newsgroup(s).