From: Yunjian Wang <wangyunjian@huawei.com>
To: <dev@dpdk.org>
Cc: <qi.z.zhang@intel.com>, <jingjing.wu@intel.com>,
<beilei.xing@intel.com>, <xudingke@huawei.com>,
<jerry.lilijun@huawei.com>, Yunjian Wang <wangyunjian@huawei.com>,
<stable@dpdk.org>
Subject: [PATCH RESEND] net/iavf: fix memoy leak in error path
Date: Thu, 14 Dec 2023 09:45:41 +0800 [thread overview]
Message-ID: <2be401c77779bdc38c8a79b006665ba623c6e2db.1701426993.git.wangyunjian@huawei.com> (raw)
Message-ID: <20231214014541.vmbU9qHOspWq3fZH8hmaLdNo2YfgfKKdgfHt3VkOTg0@z> (raw)
In iavf_security_ctx_create() allocated memory for the
'security_ctx', we should free it when memory malloc for
the 'iavf_security_ctx' fails, otherwise it will lead to
memory leak.
Fixes: 6bc987ecb860 ("net/iavf: support IPsec inline crypto")
Cc: stable@dpdk.org
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
drivers/net/iavf/iavf_ipsec_crypto.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/iavf/iavf_ipsec_crypto.c b/drivers/net/iavf/iavf_ipsec_crypto.c
index 07a69db540..d6c0180ffd 100644
--- a/drivers/net/iavf/iavf_ipsec_crypto.c
+++ b/drivers/net/iavf/iavf_ipsec_crypto.c
@@ -1518,8 +1518,11 @@ iavf_security_ctx_create(struct iavf_adapter *adapter)
if (adapter->security_ctx == NULL) {
adapter->security_ctx = rte_malloc("iavf_security_ctx",
sizeof(struct iavf_security_ctx), 0);
- if (adapter->security_ctx == NULL)
+ if (adapter->security_ctx == NULL) {
+ rte_free(adapter->vf.eth_dev->security_ctx);
+ adapter->vf.eth_dev->security_ctx = NULL;
return -ENOMEM;
+ }
}
return 0;
--
2.33.0
next reply other threads:[~2023-12-14 1:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-01 10:46 Yunjian Wang [this message]
2023-12-14 1:45 ` Yunjian Wang
2023-12-14 4:39 ` Zhang, Qi Z
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=2be401c77779bdc38c8a79b006665ba623c6e2db.1701426993.git.wangyunjian@huawei.com \
--to=wangyunjian@huawei.com \
--cc=beilei.xing@intel.com \
--cc=dev@dpdk.org \
--cc=jerry.lilijun@huawei.com \
--cc=jingjing.wu@intel.com \
--cc=qi.z.zhang@intel.com \
--cc=stable@dpdk.org \
--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).