summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatoly Burakov <anatoly.burakov@intel.com>2018-11-06 14:13:29 +0000
committerThomas Monjalon <thomas@monjalon.net>2018-11-07 00:06:38 +0100
commit4531d096d105a9ef65c516fc59e86fc0c56e46cc (patch)
treee0c7fb58e68fdc98c0101d92c83441bc4d8d5669
parent9252e81a9fc31fcad44132fde54b2e9cf8cb658f (diff)
downloaddpdk-4531d096d105a9ef65c516fc59e86fc0c56e46cc.zip
dpdk-4531d096d105a9ef65c516fc59e86fc0c56e46cc.tar.gz
dpdk-4531d096d105a9ef65c516fc59e86fc0c56e46cc.tar.xz
mem: fix use after free in legacy mem init
Adding an additional failure path in DMA mask check has exposed an issue where `hugepage` pointer may point to memory that has already been unmapped, but pointer value is still not NULL, so failure handler will attempt to unmap it second time if DMA mask check fails. Fix it by setting `hugepage` pointer to NULL once it is no longer needed. Coverity issue: 325730 Fixes: 165c89b84538 ("mem: use DMA mask check for legacy memory") Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
-rw-r--r--lib/librte_eal/linuxapp/eal/eal_memory.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
index c1b5e07..48b23ce 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -1617,6 +1617,7 @@ eal_legacy_hugepage_init(void)
tmp_hp = NULL;
munmap(hugepage, nr_hugefiles * sizeof(struct hugepage_file));
+ hugepage = NULL;
/* we're not going to allocate more pages, so release VA space for
* unused memseg lists