From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by dpdk.org (Postfix) with ESMTP id 1808A1BBB0; Fri, 27 Oct 2017 05:19:50 +0200 (CEST) Received: from 172.30.72.60 (EHLO DGGEMS405-HUB.china.huawei.com) ([172.30.72.60]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DJW45781; Fri, 27 Oct 2017 11:19:48 +0800 (CST) Received: from localhost (10.175.126.192) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.361.1; Fri, 27 Oct 2017 11:17:50 +0800 From: Pengzhen Liu To: CC: , , Date: Fri, 27 Oct 2017 11:54:09 +0800 Message-ID: <1509076449-20542-1-git-send-email-liupengzhen3@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.126.192] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.59F2A5D5.000F, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: f174451a258df2c215d8ccad49dcc730 Subject: [dpdk-stable] [PATCH] net/virtio: fix memory leak X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2017 03:19:52 -0000 In function eth_virtio_dev_init(), dynamic memory stored in "eth_dev->data->mac_addrs" variable and it is not freed when function return, this is a possible memory leak. Fixes: 8ced1542f7a3 ("net/virtio: eth_dev->data->mac_addrs is not freed") Cc: stable@dpdk.org Signed-off-by: Pengzhen Liu --- drivers/net/virtio/virtio_ethdev.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index a8ae788..59a76ad 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1588,13 +1588,13 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev, if (!hw->virtio_user_dev) { ret = vtpci_init(RTE_ETH_DEV_TO_PCI(eth_dev), hw); if (ret) - return ret; + goto out; } /* reset device and negotiate default features */ ret = virtio_init_device(eth_dev, VIRTIO_PMD_DEFAULT_GUEST_FEATURES); if (ret < 0) - return ret; + goto out; /* Setup interrupt callback */ if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) @@ -1602,6 +1602,10 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev, virtio_interrupt_handler, eth_dev); return 0; + +out: + rte_free(eth_dev->data->mac_addrs); + return ret; } static int -- 1.7.12.4