mem: fix potential underflow on mem size calculation
authorAnatoly Burakov <anatoly.burakov@intel.com>
Thu, 3 May 2018 13:03:19 +0000 (14:03 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 14 May 2018 01:15:31 +0000 (03:15 +0200)
commitd2bd796d7bd45f6a14eeb68cd4b5faee244f11ec
tree24ea3eb13707866e902abf1750083a135b621941
parent7785c5588d7e8cb07d70a4986afb3685b55ace86
mem: fix potential underflow on mem size calculation

If total memory is already bigger than max memory, an underflow
will occur on subtraction. Fix it by simply stopping whenever
we already have amount of memory that is bigger than maximum.

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

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
lib/librte_eal/common/eal_common_memory.c