vhost: fix malloc size too small

Amount of allocated memory was too small, causing buffer overflow.

Fixes: eb32247457fe ("vhost: export guest memory regions")
Cc: stable@dpdk.org

Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: Jens Freimann <jfreiman@redhat.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
This commit is contained in:
Dariusz Stojaczyk 2017-05-26 13:59:13 +02:00 committed by Yuanhan Liu
parent 29150b70ab
commit d1b2842a9d

View File

@ -369,7 +369,7 @@ rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem)
return -1;
size = dev->mem->nregions * sizeof(struct rte_vhost_mem_region);
m = malloc(size);
m = malloc(sizeof(struct rte_vhost_memory) + size);
if (!m)
return -1;