From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stephen@networkplumber.org>
Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com
 [209.85.220.45]) by dpdk.org (Postfix) with ESMTP id CDD1A5A57
 for <dev@dpdk.org>; Tue, 20 Oct 2015 20:43:58 +0200 (CEST)
Received: by pacfv9 with SMTP id fv9so29978592pac.3
 for <dev@dpdk.org>; Tue, 20 Oct 2015 11:43:58 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to
 :references:mime-version:content-type:content-transfer-encoding;
 bh=0WNusOKT17qN1AnpNfmGUDOTw04+TXbwJUsMQpOpUac=;
 b=RqBq98zg8USSQopXd+bEeCyN4KKjzVvSiMatkm1fo0sUZNdy7ZolhTlTjkEfS6uQc7
 KIEv0DFpQYCTzhAEoY60YS608xvrAtFeJ53/xWFhk57Kubk81/dp9r46P/2/ZV7d7sr5
 CcaXBj9P3pnwXiv8YKq9jK0Dl0UeXqBBJFqStBCnZC302J4y9CL4yXXB+yzlHXSaD11h
 Vp9J89j81qVY6rdBNW484MsXvEZqLmD3HhLlEGXaQyOrcK9fyJiKqoyqVmQB1r+ycIRt
 cs/Sdma36WtvAvLVZir+xJ/AkrrARmRW5kvfth1ei1w+tkhQxfAigo0dwx3gdrifLSxi
 glQg==
X-Gm-Message-State: ALoCoQkJdPUpQMRW8FdJ3wc/LrvJ0Wwrnnyxy5qQ3rNYqCVhZuj6egqTu5u4DJVQ8T9UBNU29VlV
X-Received: by 10.66.97.73 with SMTP id dy9mr5518506pab.115.1445366637833;
 Tue, 20 Oct 2015 11:43:57 -0700 (PDT)
Received: from xeon-e3 (static-50-53-82-155.bvtn.or.frontiernet.net.
 [50.53.82.155])
 by smtp.gmail.com with ESMTPSA id ir5sm5046422pbc.13.2015.10.20.11.43.57
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Tue, 20 Oct 2015 11:43:57 -0700 (PDT)
Date: Tue, 20 Oct 2015 11:44:07 -0700
From: Stephen Hemminger <stephen@networkplumber.org>
To: Bernard Iremonger <bernard.iremonger@intel.com>
Message-ID: <20151020114407.58972ed5@xeon-e3>
In-Reply-To: <1445355462-16521-1-git-send-email-bernard.iremonger@intel.com>
References: <PATCH>
 <1445355462-16521-1-git-send-email-bernard.iremonger@intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH 1/2] virtio: fixed segmentation fault in
 queue_release
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Tue, 20 Oct 2015 18:43:59 -0000

On Tue, 20 Oct 2015 16:37:41 +0100
Bernard Iremonger <bernard.iremonger@intel.com> wrote:

> if input parameter vq is NULL, hw = vq->hw, causes a segmentation fault.
> 
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> ---
>  drivers/net/virtio/virtio_ethdev.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
> index 465d3cd..147aca1 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -239,9 +239,10 @@ virtio_set_multiple_queues(struct rte_eth_dev *dev, uint16_t nb_queues)
>  
>  void
>  virtio_dev_queue_release(struct virtqueue *vq) {
> -	struct virtio_hw *hw = vq->hw;
> +	struct virtio_hw *hw;
>  
>  	if (vq) {
> +		hw = vq->hw;
>  		/* Select and deactivate the queue */
>  		VIRTIO_WRITE_REG_2(hw, VIRTIO_PCI_QUEUE_SEL, vq->queue_id);
>  		VIRTIO_WRITE_REG_4(hw, VIRTIO_PCI_QUEUE_PFN, 0);

This could only happen for the case of the control vq.
Others are guaranteed to be non NULL by rte_ethdev.

Acked-by: Stephen Hemminger <stephen@networkplumber.org>