From: Marcin Kerlin Date: Wed, 15 Jun 2016 09:47:22 +0000 (+0200) Subject: vhost: fix null pointer dereference X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b4977246521c78de47d38b0c03fe78098f20945d;p=dpdk.git vhost: fix null pointer dereference Return value of function get_device() is not checking before dereference. Fix this problem by adding checking condition. Coverity issue: 119262 Fixes: 77d20126b4c2 ("vhost-user: handle message to enable vring") Signed-off-by: Marcin Kerlin Acked-by: Yuanhan Liu --- diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c index c21ec6b09b..64a6ec42c0 100644 --- a/lib/librte_vhost/vhost_user/virtio-net-user.c +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c @@ -335,9 +335,13 @@ user_get_vring_base(int vid, struct vhost_vring_state *state) int user_set_vring_enable(int vid, struct vhost_vring_state *state) { - struct virtio_net *dev = get_device(vid); + struct virtio_net *dev; int enable = (int)state->num; + dev = get_device(vid); + if (dev == NULL) + return -1; + RTE_LOG(INFO, VHOST_CONFIG, "set queue enable: %d to qp idx: %d\n", enable, state->index);