From patchwork Thu Aug 12 15:57:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Van Haaren, Harry" X-Patchwork-Id: 1516369 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GlrwN1pBKz9sX3 for ; Fri, 13 Aug 2021 01:59:16 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 84927614B8; Thu, 12 Aug 2021 15:59:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jG0sL8MFNS8l; Thu, 12 Aug 2021 15:59:10 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id E692C6147E; Thu, 12 Aug 2021 15:59:07 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C3B77C0022; Thu, 12 Aug 2021 15:59:07 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 72062C0022 for ; Thu, 12 Aug 2021 15:59:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 1FB31407D7 for ; Thu, 12 Aug 2021 15:58:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id i0cVvB_H1MP5 for ; Thu, 12 Aug 2021 15:58:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by smtp2.osuosl.org (Postfix) with ESMTPS id 27D4F407DD for ; Thu, 12 Aug 2021 15:58:07 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10074"; a="202573091" X-IronPort-AV: E=Sophos;i="5.84,316,1620716400"; d="scan'208";a="202573091" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2021 08:57:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,316,1620716400"; d="scan'208";a="527871946" Received: from silpixa00401089.ir.intel.com ([10.55.129.12]) by fmsmga002.fm.intel.com with ESMTP; 12 Aug 2021 08:57:42 -0700 From: Harry van Haaren To: dev@openvswitch.org Date: Thu, 12 Aug 2021 15:57:34 +0000 Message-Id: <20210812155735.3113912-1-harry.van.haaren@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210812151134.3113110-1-harry.van.haaren@intel.com> References: <20210812151134.3113110-1-harry.van.haaren@intel.com> MIME-Version: 1.0 Cc: kumar.amber@intel.com, i.maximets@ovn.org Subject: [ovs-dev] [PATCH v2 1/2] dpif-netdev: fix memory leak in dpcls subtable set command X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" This patch fixes a memory leak when the command "dpif-netdev/subtable-lookup-prio-set" is run, the pmd_list required to iterate the PMD threads was not being freed. This issue was identified by a static analysis tool. Fixes: 3d018c3e ("dpif-netdev: Add subtable lookup prio set command.") Signed-off-by: Harry van Haaren Acked-by: Kevin Traynor --- Maintainers, please consider applying this patch to 2.14 and 2.15, which are expected to have the same issue as fixed here. --- lib/dpif-netdev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 03f460c7d1..9e0d5c3103 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -994,6 +994,7 @@ dpif_netdev_subtable_lookup_set(struct unixctl_conn *conn, int argc OVS_UNUSED, /* release port mutex before netdev mutex. */ ovs_mutex_unlock(&dp->port_mutex); + free(pmd_list); } ovs_mutex_unlock(&dp_netdev_mutex); From patchwork Thu Aug 12 15:57:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Van Haaren, Harry" X-Patchwork-Id: 1516370 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GlrwQ1SVFz9sX3 for ; Fri, 13 Aug 2021 01:59:18 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id DDA7E407B3; Thu, 12 Aug 2021 15:59:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mapodktNlWhb; Thu, 12 Aug 2021 15:59:12 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 9FEEE40207; Thu, 12 Aug 2021 15:59:10 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 70C82C001D; Thu, 12 Aug 2021 15:59:10 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id AB8FCC0023 for ; Thu, 12 Aug 2021 15:59:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 97833407D6 for ; Thu, 12 Aug 2021 15:58:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Adz3CodH0PNI for ; Thu, 12 Aug 2021 15:58:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by smtp2.osuosl.org (Postfix) with ESMTPS id 67771407C7 for ; Thu, 12 Aug 2021 15:58:07 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10074"; a="202573110" X-IronPort-AV: E=Sophos;i="5.84,316,1620716400"; d="scan'208";a="202573110" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2021 08:57:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,316,1620716400"; d="scan'208";a="527871963" Received: from silpixa00401089.ir.intel.com ([10.55.129.12]) by fmsmga002.fm.intel.com with ESMTP; 12 Aug 2021 08:57:45 -0700 From: Harry van Haaren To: dev@openvswitch.org Date: Thu, 12 Aug 2021 15:57:35 +0000 Message-Id: <20210812155735.3113912-2-harry.van.haaren@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210812155735.3113912-1-harry.van.haaren@intel.com> References: <20210812151134.3113110-1-harry.van.haaren@intel.com> <20210812155735.3113912-1-harry.van.haaren@intel.com> MIME-Version: 1.0 Cc: kumar.amber@intel.com, i.maximets@ovn.org Subject: [ovs-dev] [PATCH v2 2/2] dpif-netdev: fix memory leak in dpif and mfex commands X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" This patch fixes a memory leak in the commands for DPIF and MFEX get and set. In order to operate the commands require a pmd_list, which is currently not freed after it has been used. This issue was identified by a static analysis tool. Fixes: 3d8f47bc ("dpif-netdev: Add command line and function pointer for miniflow extract") Fixes: abb807e2 ("dpif-netdev: Add command to switch dpif implementation.") Signed-off-by: Harry van Haaren Acked-by: Kevin Traynor --- Maintainers; these mem leaks were introduced in this release, so are not candidates for backporting. --- lib/dpif-netdev.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 9e0d5c3103..37a5839684 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -1025,6 +1025,7 @@ dpif_netdev_impl_get(struct unixctl_conn *conn, int argc OVS_UNUSED, * thread. */ sorted_poll_thread_list(dp, &pmd_list, &n); dp_netdev_impl_get(&reply, pmd_list, n); + free(pmd_list); } ovs_mutex_unlock(&dp_netdev_mutex); unixctl_command_reply(conn, ds_cstr(&reply)); @@ -1079,6 +1080,8 @@ dpif_netdev_impl_set(struct unixctl_conn *conn, int argc OVS_UNUSED, atomic_uintptr_t *pmd_func = (void *) &pmd->netdev_input_func; atomic_store_relaxed(pmd_func, (uintptr_t) default_func); }; + + free(pmd_list); } ovs_mutex_unlock(&dp_netdev_mutex); @@ -1109,6 +1112,7 @@ dpif_miniflow_extract_impl_get(struct unixctl_conn *conn, int argc OVS_UNUSED, * thread. */ sorted_poll_thread_list(dp, &pmd_list, &n); dp_mfex_impl_get(&reply, pmd_list, n); + free(pmd_list); } ovs_mutex_unlock(&dp_netdev_mutex); unixctl_command_reply(conn, ds_cstr(&reply)); @@ -1267,6 +1271,8 @@ dpif_miniflow_extract_impl_set(struct unixctl_conn *conn, int argc, atomic_uintptr_t *pmd_func = (void *) &pmd->miniflow_extract_opt; atomic_store_relaxed(pmd_func, (uintptr_t) mfex_func); }; + + free(pmd_list); } ovs_mutex_unlock(&dp_netdev_mutex);