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 <marcinx.kerlin@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
This commit is contained in:
Marcin Kerlin 2016-06-15 11:47:22 +02:00 committed by Yuanhan Liu
parent 39449e7429
commit b497724652

View File

@ -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);