From: Long Li <longli@microsoft.com>
To: wangyunjian <wangyunjian@huawei.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: Stephen Hemminger <sthemmin@microsoft.com>,
KY Srinivasan <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
"jerry.lilijun@huawei.com" <jerry.lilijun@huawei.com>,
"xudingke@huawei.com" <xudingke@huawei.com>,
"stable@dpdk.org" <stable@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2] net/netvsc: fix txq leak in error path
Date: Fri, 9 Oct 2020 03:53:30 +0000 [thread overview]
Message-ID: <BYAPR21MB11596B362F3172D09C34BBD9CE080@BYAPR21MB1159.namprd21.prod.outlook.com> (raw)
In-Reply-To: <1602036385-10760-1-git-send-email-wangyunjian@huawei.com>
>Subject: [dpdk-dev] [PATCH v2] net/netvsc: fix txq leak in error path
>
>From: Yunjian Wang <wangyunjian@huawei.com>
>
>In hn_dev_tx_queue_setup() allocated memory for txq, we don't free it
>when error happens and it will lead to memory leak.
>
>We can check for tx_free_thresh at the beginning of the function to fix it,
>before calling txq = rte_zmalloc_socket().
>
>Fixes: cc0251813277 ("net/netvsc: split send buffers from Tx descriptors")
>Cc: stable@dpdk.org
>
>Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Acked-by: Long Li <longli@microsoft.com>
>---
>v2:
> fix code styles suggested by Long Li
>---
> drivers/net/netvsc/hn_rxtx.c | 19 +++++++++----------
> 1 file changed, 9 insertions(+), 10 deletions(-)
>
>diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
>index 65f1abae5..5d59db513 100644
>--- a/drivers/net/netvsc/hn_rxtx.c
>+++ b/drivers/net/netvsc/hn_rxtx.c
>@@ -252,16 +252,6 @@ hn_dev_tx_queue_setup(struct rte_eth_dev *dev,
>
> PMD_INIT_FUNC_TRACE();
>
>- txq = rte_zmalloc_socket("HN_TXQ", sizeof(*txq),
>RTE_CACHE_LINE_SIZE,
>- socket_id);
>- if (!txq)
>- return -ENOMEM;
>-
>- txq->hv = hv;
>- txq->chan = hv->channels[queue_idx];
>- txq->port_id = dev->data->port_id;
>- txq->queue_id = queue_idx;
>-
> tx_free_thresh = tx_conf->tx_free_thresh;
> if (tx_free_thresh == 0)
> tx_free_thresh = RTE_MIN(nb_desc / 4, @@ -276,6 +266,15
>@@ hn_dev_tx_queue_setup(struct rte_eth_dev *dev,
> return -EINVAL;
> }
>
>+ txq = rte_zmalloc_socket("HN_TXQ", sizeof(*txq),
>RTE_CACHE_LINE_SIZE,
>+ socket_id);
>+ if (!txq)
>+ return -ENOMEM;
>+
>+ txq->hv = hv;
>+ txq->chan = hv->channels[queue_idx];
>+ txq->port_id = dev->data->port_id;
>+ txq->queue_id = queue_idx;
> txq->free_thresh = tx_free_thresh;
>
> snprintf(name, sizeof(name),
>--
>2.23.0
next prev parent reply other threads:[~2020-10-09 3:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-29 13:44 [dpdk-dev] [PATCH] " wangyunjian
2020-09-30 22:27 ` Long Li
2020-10-02 14:25 ` Yunjian Wang
2020-10-07 2:06 ` [dpdk-dev] [PATCH v2] " wangyunjian
2020-10-09 3:53 ` Long Li [this message]
2020-10-09 11:36 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BYAPR21MB11596B362F3172D09C34BBD9CE080@BYAPR21MB1159.namprd21.prod.outlook.com \
--to=longli@microsoft.com \
--cc=dev@dpdk.org \
--cc=haiyangz@microsoft.com \
--cc=jerry.lilijun@huawei.com \
--cc=kys@microsoft.com \
--cc=stable@dpdk.org \
--cc=sthemmin@microsoft.com \
--cc=wangyunjian@huawei.com \
--cc=xudingke@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).