Skip to content

Commit

Permalink
net/mlx5e: fix memory leak of tls
Browse files Browse the repository at this point in the history
The error return path when create_singlethread_workqueue fails currently
does not kfree tls and leads to a memory leak. Fix this by kfree'ing
tls before returning -ENOMEM.

Addresses-Coverity: ("Resource leak")
Fixes: 1182f36 ("net/mlx5e: kTLS, Add kTLS RX HW offload support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Colin Ian King authored and David S. Miller committed Jun 30, 2020
1 parent 6bad912 commit 5831b33
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,10 @@ int mlx5e_tls_init(struct mlx5e_priv *priv)
return -ENOMEM;

tls->rx_wq = create_singlethread_workqueue("mlx5e_tls_rx");
if (!tls->rx_wq)
if (!tls->rx_wq) {
kfree(tls);
return -ENOMEM;
}

priv->tls = tls;
return 0;
Expand Down

0 comments on commit 5831b33

Please sign in to comment.