From: Jianfeng Tan Date: Tue, 5 Jul 2016 11:42:59 +0000 (+0000) Subject: net/virtio: fix null pointer dereference X-Git-Tag: spdx-start~6221 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=3bd60a27e9f2afacff70f6aafdca0fc18685633f;p=dpdk.git net/virtio: fix null pointer dereference There is a logic bug in this code, that could lead to null pointer dereference when cvq is NULL. Fix this problem by changing logic && to logic ||. >> CID 127480: Null pointer dereferences (FORWARD_NULL) >> Dereferencing null pointer "cvq". if (!cvq && !cvq->vq) { ... } Coverity issue: 127480 Fixes: 01ad44fd374f ("net/virtio: split Rx/Tx queue") Signed-off-by: Jianfeng Tan Acked-by: Yuanhan Liu --- diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index e6c2ac2110..8467b3c05b 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -166,7 +166,7 @@ virtio_send_command(struct virtnet_ctl *cvq, struct virtio_pmd_ctrl *ctrl, ctrl->status = status; - if (!cvq && !cvq->vq) { + if (!cvq || !cvq->vq) { PMD_INIT_LOG(ERR, "Control queue is not supported."); return -1; }