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 33F5EA0C54; Fri, 27 Aug 2021 04:08:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AFEC04067C; Fri, 27 Aug 2021 04:08:07 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 7D21640140; Fri, 27 Aug 2021 04:08:06 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="198118362" X-IronPort-AV: E=Sophos;i="5.84,355,1620716400"; d="scan'208";a="198118362" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 19:08:05 -0700 X-IronPort-AV: E=Sophos;i="5.84,355,1620716400"; d="scan'208";a="495433269" Received: from unknown (HELO localhost.localdomain) ([10.240.183.109]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 19:08:02 -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: Fri, 27 Aug 2021 14:00:37 +0000 Message-Id: <20210827140037.3822-1-wenwux.ma@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210817171320.647414-1-wenwux.ma@intel.com> References: <20210817171320.647414-1-wenwux.ma@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2] 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 v2: - Delete '.' in the title. 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