Commit d543b649 authored by Zhengchao Shao's avatar Zhengchao Shao Committed by Saeed Mahameed
Browse files

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: 145e5637 ("net/mlx5e: Add TX PTP port object support")
Signed-off-by: default avatarZhengchao Shao <shaozhengchao@huawei.com>
Reviewed-by: default avatarRahul Rameshbabu <rrameshbabu@nvidia.com>
Reviewed-by: default avatarGal Pressman <gal@nvidia.com>
Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 3250affd
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -729,8 +729,10 @@ int mlx5e_ptp_open(struct mlx5e_priv *priv, struct mlx5e_params *params,

	c = kvzalloc_node(sizeof(*c), GFP_KERNEL, dev_to_node(mlx5_core_dma_dev(mdev)));
	cparams = kvzalloc(sizeof(*cparams), GFP_KERNEL);
	if (!c || !cparams)
		return -ENOMEM;
	if (!c || !cparams) {
		err = -ENOMEM;
		goto err_free;
	}

	c->priv     = priv;
	c->mdev     = priv->mdev;