eal: fix leak in shared lib mode detection
PATCH 1/1 eal: fix leak in shared lib mode detection
This is reported by our internal covscan:
1. dpdk-20.11/lib/librte_eal/common/eal_common_options.c:508: alloc_fn:
Storage is returned from allocation function "dlopen".
6. dpdk-20.11/lib/librte_eal/common/eal_common_options.c:508:leaked_storage: Failing to save or free storage allocated by "dlopen("librte_eal.so.21.0", 5)" leaks it.
# 506| * shared library is not already loaded i.e. it's
# statically linked.)
# 507| */
# 508|-> if (dlopen("librte_eal.so."ABI_VERSION, RTLD_LAZY |
# RTLD_NOLOAD) != NULL &&
# 509| *default_solib_dir != '\0' &&
# 510| stat(default_solib_dir, &sb) == 0 &&This leak is not an issue per se, but on the other hand, this is easy to fix and I prefer not having to waive this warning later.
--- lib/eal/common/eal_common_options.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
lib/eal/common/eal_common_options.c +5 -1
@@ -509,10 +509,14 @@ is_shared_build(void) }while (len >= minlen) { +void *handle; +/* check if we have this .so loaded, if so - shared build */ RTE_LOG (DEBUG ,EAL ,"Checking presence of .so '%s'\n" , soname); -if (dlopen (soname,RTLD_LAZY |RTLD_NOLOAD ) !=NULL ) { + handle =dlopen (soname,RTLD_LAZY |RTLD_NOLOAD ); +if (handle !=NULL ) {RTE_LOG (INFO ,EAL ,"Detected shared linkage of DPDK\n" ); +dlclose (handle);return 1 ; }
Signature · 1 line
2.23.0
Quoted 37 lines · David Marchand
This is reported by our internal covscan:
1.
dpdk-20.11/lib/librte_eal/common/eal_common_options.c:508:alloc_fn:
Storage is returned from allocation function "dlopen".
6.dpdk-20.11/lib/librte_eal/common/eal_common_options.c:508:leaked_storage: Failing to save or free storage allocated by "dlopen("librte_eal.so.21.0", 5)" leaks it.# 506| * shared library is not already loaded i.e. it's # statically linked.) # 507| */ # 508|-> if (dlopen("librte_eal.so."ABI_VERSION, RTLD_LAZY | # RTLD_NOLOAD) != NULL && # 509| *default_solib_dir != '\0' && # 510| stat(default_solib_dir, &sb) == 0 &&This leak is not an issue per se, but on the other hand, this is easy to fix and I prefer not having to waive this warning later.
Fixes 06c7871dde01 ("eal: restrict default plugin path to shared lib mode")Signed-off-by David Marchand <[email protected]>--- lib/eal/common/eal_common_options.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)lib/eal/common/eal_common_options.c +2
-0@@ -509,10 +509,14 @@ is_shared_build(void) }while (len >= minlen) { +void *handle; +
lib/eal/common/eal_common_options.c is_shared_build(void) · line 522
Quoted 10 lines
lib/eal/common/eal_common_options.c +3
-1/* check if we have this .so loaded, if so - shared build */ RTE_LOG (DEBUG ,EAL ,"Checking presence of .so '%s'\n" , soname); -if (dlopen (soname,RTLD_LAZY |RTLD_NOLOAD ) !=NULL ) { + handle =dlopen (soname,RTLD_LAZY |RTLD_NOLOAD ); +if (handle !=NULL ) {RTE_LOG (INFO ,EAL ,"Detected shared linkage of DPDK\n" ); +dlclose (handle);return 1 ; }
Since this is not really a leak, I'm not sure it needs backport, but no harm in CC'ing stable and letting maintainers choose.
Thomas Monjalon
Applied06/05/2021 12:40, Bruce Richardson:
Quoted 20 lines · David Marchand
Quoted 19 lines
This is reported by our internal covscan:
1.
dpdk-20.11/lib/librte_eal/common/eal_common_options.c:508:alloc_fn:
Storage is returned from allocation function "dlopen".
6.dpdk-20.11/lib/librte_eal/common/eal_common_options.c:508:leaked_storage: Failing to save or free storage allocated by "dlopen("librte_eal.so.21.0", 5)" leaks it.# 506| * shared library is not already loaded i.e. it's # statically linked.) # 507| */ # 508|-> if (dlopen("librte_eal.so."ABI_VERSION, RTLD_LAZY | # RTLD_NOLOAD) != NULL && # 509| *default_solib_dir != '\0' && # 510| stat(default_solib_dir, &sb) == 0 &&This leak is not an issue per se, but on the other hand, this is easy to fix and I prefer not having to waive this warning later.
Quoted 6 lines
Quoted 4 lines
Fixes 06c7871dde01 ("eal: restrict default plugin path to shared lib mode")Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>
Applied, thanks