Skip to content

Commit

Permalink
net/iavf: fix memory leak on security context error
Browse files Browse the repository at this point in the history
[ upstream commit 8758ad5f8633ce4197271d41ece0cc7f799d3d6e ]

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: 6bc987e ("net/iavf: support IPsec inline crypto")

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
  • Loading branch information
wyjwang authored and kevintraynor committed Mar 5, 2024
1 parent 3c1d8f3 commit 835b8ab
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/iavf/iavf_ipsec_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -1497,8 +1497,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;
Expand Down

0 comments on commit 835b8ab

Please sign in to comment.