malloc: fix out-of-bounds segment array access
authorAnatoly Burakov <anatoly.burakov@intel.com>
Mon, 16 Apr 2018 16:45:00 +0000 (17:45 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 27 Apr 2018 21:52:51 +0000 (23:52 +0200)
commit0af8db317267544e86b271008360d9847973f92c
treed03ea851c3403a79340f1eee80e8ccd0f99f29fe
parent627e80e4f6c6c886d2c48e481575f29c05cf4807
malloc: fix out-of-bounds segment array access

Technically, while the pointer would've been invalid if msl_idx
were invalid, we wouldn't have actually attempted to access the
pointer until verifying the index. Fix it by moving array access
to after we've verified validity of the index.

Coverity issue: 272574
Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists")

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
lib/librte_eal/common/malloc_heap.c