[1/1] net/iavf: fix memoy leak in error path
Checks
Commit Message
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(-)
Comments
> -----Original Message-----
> From: Yunjian Wang <wangyunjian@huawei.com>
> Sent: Thursday, December 14, 2023 9:46 AM
> To: dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>;
> Xing, Beilei <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
>
> 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>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Thanks
Qi
@@ -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;