eal: fix leak in shared lib mode detection
authorDavid Marchand <david.marchand@redhat.com>
Thu, 6 May 2021 10:06:37 +0000 (12:06 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 10 May 2021 13:31:42 +0000 (15:31 +0200)
commitb81bf1efe3ff7bf6bedf4dcce1e3fb90ac9c8d3c
treeea9d811bb1b793d3617f6de0e2fb39ec18774676
parentb353f17b6dd80b0c3209cc5dc760f5b8ecff357c
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.

Fixes: 06c7871dde01 ("eal: restrict default plugin path to shared lib mode")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
lib/eal/common/eal_common_options.c