mem: fix potential resource leak on freeing
authorAnatoly Burakov <anatoly.burakov@intel.com>
Mon, 16 Apr 2018 15:31:08 +0000 (16:31 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 27 Apr 2018 21:42:40 +0000 (23:42 +0200)
commitb48f859a0397225f5484fd9fd78a3b6567e12f77
tree35141273e0d9a41695259b852c882ead714b364d
parent6f0fa9f238320669b024e8f36184b621d9ab2fb3
mem: fix potential resource leak on freeing

We close fd if we managed to find it in the list of allocated
segment lists (which should always be the case under normal
conditions), but if we didn't, the fd was leaking. Close it if
we couldn't find it in the segment list. This is not an issue
as if the segment is zero length, we're getting rid of it
anyway, so there's no harm in not storing the fd anywhere.

Coverity issue: 272568
Fixes: 2a04139f66b4 ("eal: add single file segments option")

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
lib/librte_eal/linuxapp/eal/eal_memalloc.c