net/mlx5e: fix memory leak in mlx5e_ptp_open
authorZhengchao Shao <shaozhengchao@huawei.com>
Fri, 30 Jun 2023 01:49:03 +0000 (09:49 +0800)
committerSaeed Mahameed <saeedm@nvidia.com>
Wed, 5 Jul 2023 17:57:03 +0000 (10:57 -0700)
commitd543b649ffe58a0cb4b6948b3305069c5980a1fa
tree133c86598411c96ac1f0f1801e37e15d6c1fc89b
parent3250affdc658557a41df9c5fb567723e421f8bf2
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: 145e5637d941 ("net/mlx5e: Add TX PTP port object support")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
Reviewed-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c