summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorYuanhan Liu <yuanhan.liu@linux.intel.com>2016-07-19 10:39:53 +0800
committerThomas Monjalon <thomas.monjalon@6wind.com>2016-07-22 00:30:08 +0200
commit834ac655bae247acee5016dc46400f456db047fd (patch)
tree6c90c9a3f65992b1fc5b5a0225a034687e21e738 /drivers
parent25f80d1087809b6efedc85923310f571aae2668f (diff)
downloaddpdk-834ac655bae247acee5016dc46400f456db047fd.zip
dpdk-834ac655bae247acee5016dc46400f456db047fd.tar.gz
dpdk-834ac655bae247acee5016dc46400f456db047fd.tar.xz
net/virtio: fix crash on null dereference
The rxq/txq for the queue_release callback could be NULL, say when rte_eth_dev_configure() fails that the queue is not setup at all. Do a simple NULL check would fix the crash issue. Fixes: 01ad44fd374f ("net/virtio: split Rx/Tx queue") Reported-by: Olivier Matz <olivier.matz@6wind.com> Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/virtio/virtio_rxtx.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index 9aba044..724517e 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -468,13 +468,19 @@ void
virtio_dev_rx_queue_release(void *rxq)
{
struct virtnet_rx *rxvq = rxq;
- struct virtqueue *vq = rxvq->vq;
- /* rxvq is freed when vq is freed, and as mz should be freed after the
+ struct virtqueue *vq;
+ const struct rte_memzone *mz;
+
+ if (rxvq == NULL)
+ return;
+
+ /*
+ * rxvq is freed when vq is freed, and as mz should be freed after the
* del_queue, so we reserve the mz pointer first.
*/
- const struct rte_memzone *mz = rxvq->mz;
+ vq = rxvq->vq;
+ mz = rxvq->mz;
- /* no need to free rxq as vq and rxq are allocated together */
virtio_dev_queue_release(vq);
rte_memzone_free(mz);
}
@@ -554,12 +560,20 @@ void
virtio_dev_tx_queue_release(void *txq)
{
struct virtnet_tx *txvq = txq;
- struct virtqueue *vq = txvq->vq;
- /* txvq is freed when vq is freed, and as mz should be freed after the
+ struct virtqueue *vq;
+ const struct rte_memzone *mz;
+ const struct rte_memzone *hdr_mz;
+
+ if (txvq == NULL)
+ return;
+
+ /*
+ * txvq is freed when vq is freed, and as mz should be freed after the
* del_queue, so we reserve the mz pointer first.
*/
- const struct rte_memzone *hdr_mz = txvq->virtio_net_hdr_mz;
- const struct rte_memzone *mz = txvq->mz;
+ vq = txvq->vq;
+ mz = txvq->mz;
+ hdr_mz = txvq->virtio_net_hdr_mz;
virtio_dev_queue_release(vq);
rte_memzone_free(mz);