Skip to content

Commit d543b64

Browse files
zhengchaoshaoSaeed Mahameed
authored andcommitted
net/mlx5e: fix memory leak in mlx5e_ptp_open
When kvzalloc_node or kvzalloc failed in mlx5e_ptp_open, the memory pointed by "c" or "cparams" is not freed, which can lead to a memory leak. Fix by freeing the array in the error path. Fixes: 145e563 ("net/mlx5e: Add TX PTP port object support") Signed-off-by: Zhengchao Shao <[email protected]> Reviewed-by: Rahul Rameshbabu <[email protected]> Reviewed-by: Gal Pressman <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 3250aff commit d543b64

File tree

1 file changed

+4
-2
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en

1 file changed

+4
-2
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,10 @@ int mlx5e_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params,
729729

730730
c = kvzalloc_node(sizeof(*c), GFP_KERNEL, dev_to_node(mlx5_core_dma_dev(mdev)));
731731
cparams = kvzalloc(sizeof(*cparams), GFP_KERNEL);
732-
if (!c || !cparams)
733-
return -ENOMEM;
732+
if (!c || !cparams) {
733+
err = -ENOMEM;
734+
goto err_free;
735+
}
734736

735737
c->priv = priv;
736738
c->mdev = priv->mdev;

0 commit comments

Comments
 (0)