mem: fix cleanup after incomplete initialization
authorDmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Fri, 9 Apr 2021 17:16:31 +0000 (20:16 +0300)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 20 Apr 2021 21:33:03 +0000 (23:33 +0200)
commitff4cf5265cc9dfdf41eabaded8617f73afb1283e
treecfb6039b1f7d0de41b8715c89bd80004fef57112
parent28ebff11c2dc2d6cc862f6c19ad1b1ec64fbcc3a
mem: fix cleanup after incomplete initialization

In case of EAL initialization failure rte_eal_memory_detach() may be
called before mapping memory configuration, which in this case points
to the static structure. Attempt to unmap it yields error:

    EAL: Could not unmap shared memory config: Invalid argument

Skip unmapping memory configuration if it's not yet shared.

Fixes: dfbc61a2f9a6 ("mem: detach memsegs on cleanup")

Reported-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
lib/librte_eal/common/eal_common_memory.c