From: Stephen Hemminger <stephen@networkplumber.org>
To: huawei.xie@intel.com, changchun.ouyang@intel.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 3/3] virtio: fix possible NULL dereference
Date: Fri, 28 Aug 2015 09:23:39 -0700 [thread overview]
Message-ID: <1440779019-10793-4-git-send-email-stephen@networkplumber.org> (raw)
In-Reply-To: <1440779019-10793-1-git-send-email-stephen@networkplumber.org>
Found by Coverity. In virtio_dev_queue_release if the queue pointer is
NULL, then driver is dereferencing it to get hw pointer.
Also, don't do useless assignment
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/virtio/virtio_ethdev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 338d891..914c73d 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -239,15 +239,15 @@ 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;
if (vq) {
+ struct virtio_hw *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);
rte_free(vq);
- vq = NULL;
}
}
--
2.1.4
next prev parent reply other threads:[~2015-08-28 16:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-28 16:23 [dpdk-dev] [PATCH 0/3] virtio: patches for 2.1+ Stephen Hemminger
2015-08-28 16:23 ` [dpdk-dev] [PATCH 1/3] virtio: don't report link state feature unless available Stephen Hemminger
2015-08-31 2:54 ` Ouyang, Changchun
2015-08-28 16:23 ` [dpdk-dev] [PATCH 2/3] virtio: fix Coverity unsigned warnings Stephen Hemminger
2015-08-31 1:38 ` Ouyang, Changchun
2015-08-31 16:44 ` Stephen Hemminger
2015-08-28 16:23 ` Stephen Hemminger [this message]
2015-08-31 1:07 ` [dpdk-dev] [PATCH 3/3] virtio: fix possible NULL dereference Ouyang, Changchun
2015-10-21 14:18 ` [dpdk-dev] [PATCH 0/3] virtio: patches for 2.1+ 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=1440779019-10793-4-git-send-email-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=changchun.ouyang@intel.com \
--cc=dev@dpdk.org \
--cc=huawei.xie@intel.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).