dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: Damjan Marion <damarion@cisco.com>
To: dev@dpdk.org
Cc: Damjan Marion <damarion@cisco.com>
Subject: [PATCH] virtio: fix crash if CQ is not negotiated
Date: Mon, 25 May 2015 12:20:52 +0200	[thread overview]
Message-ID: <1432549252-8630-1-git-send-email-damarion@cisco.com> (raw)

Fix NULL dereference if virtio control queue is not negotiated.

Signed-off-by: Damjan Marion <damarion@cisco.com>
---
 drivers/net/virtio/virtio_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index f74e413..3633fce 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -114,19 +114,20 @@ static int
 virtio_send_command(struct virtqueue *vq, struct virtio_pmd_ctrl *ctrl,
 		int *dlen, int pkt_num)
 {
-	uint16_t head = vq->vq_desc_head_idx, i;
+	uint32_t head, i;
 	int k, sum = 0;
 	virtio_net_ctrl_ack status = ~0;
 	struct virtio_pmd_ctrl result;
 
 	ctrl->status = status;
 
-	if (!vq->hw->cvq) {
+	if (!(vq && vq->hw->cvq)) {
 		PMD_INIT_LOG(ERR,
 			     "%s(): Control queue is not supported.",
 			     __func__);
 		return -1;
 	}
+	head = vq->vq_desc_head_idx;
 
 	PMD_INIT_LOG(DEBUG, "vq->vq_desc_head_idx = %d, status = %d, "
 		"vq->hw->cvq = %p vq = %p",
-- 
2.1.4

             reply	other threads:[~2015-05-25 10:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-25 10:20 Damjan Marion [this message]
2015-05-26 14:59 ` [PATCH] virtio: fix crash if CQ is not negotiated Stephen Hemminger
2015-06-12 12:50   ` Thomas Monjalon

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=1432549252-8630-1-git-send-email-damarion@cisco.com \
    --to=damarion@cisco.com \
    --cc=dev@dpdk.org \
    /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).