From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 46D44A0524; Thu, 6 May 2021 12:07:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BFFD5410DB; Thu, 6 May 2021 12:07:03 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id 14A3140040 for ; Thu, 6 May 2021 12:07:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620295622; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AR1oGOhCXp2WbX8PQWfwPOniv77ZoFSk9bw1++Pslok=; b=csgxlZLEoCx/bVPDqGKI10eXEJTnXCx0WybY/u/P5w6huR1i8XyCOG+rcr5VuZRrG75JNf Lg0ytfacXx9TdbJRqQ0U4N68DutvxKvHG9gXIurxwqdiWuKcEtGU2BAgBixEQQHwmRsHKU zCeg1O3cWPDj7sPcyiN60lNT9PHO0bE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-235-Zky_7WM9P-ujg4j1xxAyHw-1; Thu, 06 May 2021 06:06:58 -0400 X-MC-Unique: Zky_7WM9P-ujg4j1xxAyHw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 296AC107ACE4; Thu, 6 May 2021 10:06:57 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.192.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9862E60DCD; Thu, 6 May 2021 10:06:54 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stable@dpdk.org, Anatoly Burakov , Stephen Hemminger , Bruce Richardson Date: Thu, 6 May 2021 12:06:37 +0200 Message-Id: <20210506100637.23645-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-dev] [PATCH] eal: fix leak in shared lib mode detection X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- lib/eal/common/eal_common_options.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c index 97ab6e00fd..ff5861b5f3 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -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; } -- 2.23.0