Skip to contentSkip to conversation

mem: fix cleanup after incomplete initialization

PATCH Applied Dmitry Kozlyuk 3 participants 3 messages Apr 9, 2021 – Apr 20, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
Cc Anatoly Burakov <[email protected]>
---
 lib/librte_eal/common/eal_common_memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/common/eal_common_memory.c +1 -1
index 2581dd5f58..f83b75092e 100644
@@ -1055,7 +1055,7 @@ rte_eal_memory_detach(void)
 	 * config - we can't zero it out because it might still be referenced
 	 * by other processes.
 	 */
-	if (internal_conf->no_shconf == 0) {
+	if (internal_conf->no_shconf == 0 && mcfg->mem_cfg_addr != 0) {
 		if (rte_mem_unmap(mcfg, RTE_ALIGN(sizeof(*mcfg), page_sz)) != 0)
 			RTE_LOG(ERR, EAL, "Could not unmap shared memory config: %s\n",
 					rte_strerror(rte_errno));
Signature · 1 line
2.29.3
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dmitry Kozlyuk

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

Quoted 8 lines

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

Fixes dfbc61a2f9a6 ("mem: detach memsegs on cleanup")
Cc Anatoly Burakov <[email protected]>

---

Signature · 2 lines
Thanks,
Anatoly
#2 lore raw

20/04/2021 18:49, Burakov, Anatoly:

Quoted 9 lines · Dmitry Kozlyuk
Quoted 8 lines

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.

Quoted 7 lines
Quoted 5 lines
Fixes dfbc61a2f9a6 ("mem: detach memsegs on cleanup")
Cc Anatoly Burakov <[email protected]>

Applied, thanks