[PATCH RESEND] net/iavf: fix memoy leak in error path
Yunjian Wang
wangyunjian at huawei.com
Thu Dec 14 02:45:41 CET 2023
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 at dpdk.org
Signed-off-by: Yunjian Wang <wangyunjian at 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
More information about the stable
mailing list