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 6B610A0548; Tue, 17 Aug 2021 07:20:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E40DA40143; Tue, 17 Aug 2021 07:20:40 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 3482C40142; Tue, 17 Aug 2021 07:20:38 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10078"; a="238074921" X-IronPort-AV: E=Sophos;i="5.84,328,1620716400"; d="scan'208";a="238074921" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 22:20:36 -0700 X-IronPort-AV: E=Sophos;i="5.84,328,1620716400"; d="scan'208";a="462254913" Received: from unknown (HELO localhost.localdomain) ([10.240.183.109]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 22:20:31 -0700 From: Wenwu Ma To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com, cheng1.jiang@intel.com, jiayu.hu@intel.com, Wenwu Ma , stable@dpdk.org Date: Tue, 17 Aug 2021 17:13:20 +0000 Message-Id: <20210817171320.647414-1-wenwux.ma@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] examples/vhost: fix memory leak on forwarding packets. 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" In function virtio_tx_local(), when the device receiving the packet is the same as the device to which the packet is forwarded, or the device is removed, we return but not free the packet, it will cause a memory leak. Fixes: 4796ad63ba1f ("examples/vhost: import userspace vhost application") Cc: stable@dpdk.org Signed-off-by: Wenwu Ma --- examples/vhost/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index bc3d71c898..07fd90ec64 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -965,6 +965,7 @@ virtio_tx_local(struct vhost_dev *vdev, struct rte_mbuf *m) return -1; if (vdev->vid == dst_vdev->vid) { + rte_pktmbuf_free(m); RTE_LOG_DP(DEBUG, VHOST_DATA, "(%d) TX: src and dst MAC is same. Dropping packet.\n", vdev->vid); @@ -975,6 +976,7 @@ virtio_tx_local(struct vhost_dev *vdev, struct rte_mbuf *m) "(%d) TX: MAC address is local\n", dst_vdev->vid); if (unlikely(dst_vdev->remove)) { + rte_pktmbuf_free(m); RTE_LOG_DP(DEBUG, VHOST_DATA, "(%d) device is marked for removal\n", dst_vdev->vid); return 0; -- 2.25.1