From d1b2842a9dcf1e7957a185be126f4af9885f9cf7 Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Fri, 26 May 2017 13:59:13 +0200 Subject: [PATCH] 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 Reviewed-by: Jens Freimann Acked-by: Yuanhan Liu --- lib/librte_vhost/vhost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index 1b8e6bd70a..19c5a43a51 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -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; -- 2.20.1