* [PATCH net,v2 0/2] fix two memory leak issues for mlx5en driver
@ 2023-06-30 1:49 Zhengchao Shao
2023-06-30 1:49 ` [PATCH net,v2 1/2] net/mlx5e: fix memory leak in mlx5e_fs_tt_redirect_any_create Zhengchao Shao
2023-06-30 1:49 ` [PATCH net,v2 2/2] net/mlx5e: fix memory leak in mlx5e_ptp_open Zhengchao Shao
0 siblings, 2 replies; 5+ messages in thread
From: Zhengchao Shao @ 2023-06-30 1:49 UTC (permalink / raw)
To: netdev, linux-rdma, davem, edumazet, kuba, pabeni, richardcochran
Cc: saeedm, leon, lkayal, tariqt, gal, rrameshbabu, vadfed, ayal,
eranbe, weiyongjun1, yuehaibing, shaozhengchao
Fix two memory leak issues for mlx5en driver:
1. fix memory leak in mlx5e_fs_tt_redirect_any_create
2. fix memory leak in mlx5e_ptp_open
Zhengchao Shao (2):
net/mlx5e: fix memory leak in mlx5e_fs_tt_redirect_any_create
net/mlx5e: fix memory leak in mlx5e_ptp_open
drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c | 6 +++---
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c | 6 ++++--
2 files changed, 7 insertions(+), 5 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net,v2 1/2] net/mlx5e: fix memory leak in mlx5e_fs_tt_redirect_any_create
2023-06-30 1:49 [PATCH net,v2 0/2] fix two memory leak issues for mlx5en driver Zhengchao Shao
@ 2023-06-30 1:49 ` Zhengchao Shao
2023-06-30 3:18 ` Rahul Rameshbabu
2023-06-30 1:49 ` [PATCH net,v2 2/2] net/mlx5e: fix memory leak in mlx5e_ptp_open Zhengchao Shao
1 sibling, 1 reply; 5+ messages in thread
From: Zhengchao Shao @ 2023-06-30 1:49 UTC (permalink / raw)
To: netdev, linux-rdma, davem, edumazet, kuba, pabeni, richardcochran
Cc: saeedm, leon, lkayal, tariqt, gal, rrameshbabu, vadfed, ayal,
eranbe, weiyongjun1, yuehaibing, shaozhengchao
The memory pointed to by the fs->any pointer is not freed in the error
path of mlx5e_fs_tt_redirect_any_create, which can lead to a memory leak.
Fix by freeing the memory in the error path, thereby making the error path
identical to mlx5e_fs_tt_redirect_any_destroy().
Fixes: 0f575c20bf06 ("net/mlx5e: Introduce Flow Steering ANY API")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
---
v2: update the 'any' member reference in fs to NULL before free fs_any
---
drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c b/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c
index 03cb79adf912..be83ad9db82a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c
@@ -594,7 +594,7 @@ int mlx5e_fs_tt_redirect_any_create(struct mlx5e_flow_steering *fs)
err = fs_any_create_table(fs);
if (err)
- return err;
+ goto err_free_any;
err = fs_any_enable(fs);
if (err)
@@ -606,8 +606,8 @@ int mlx5e_fs_tt_redirect_any_create(struct mlx5e_flow_steering *fs)
err_destroy_table:
fs_any_destroy_table(fs_any);
-
- kfree(fs_any);
+err_free_any:
mlx5e_fs_set_any(fs, NULL);
+ kfree(fs_any);
return err;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net,v2 2/2] net/mlx5e: fix memory leak in mlx5e_ptp_open
2023-06-30 1:49 [PATCH net,v2 0/2] fix two memory leak issues for mlx5en driver Zhengchao Shao
2023-06-30 1:49 ` [PATCH net,v2 1/2] net/mlx5e: fix memory leak in mlx5e_fs_tt_redirect_any_create Zhengchao Shao
@ 2023-06-30 1:49 ` Zhengchao Shao
2023-06-30 13:22 ` Simon Horman
1 sibling, 1 reply; 5+ messages in thread
From: Zhengchao Shao @ 2023-06-30 1:49 UTC (permalink / raw)
To: netdev, linux-rdma, davem, edumazet, kuba, pabeni, richardcochran
Cc: saeedm, leon, lkayal, tariqt, gal, rrameshbabu, vadfed, ayal,
eranbe, weiyongjun1, yuehaibing, shaozhengchao
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>
---
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
index 3cbebfba582b..b0b429a0321e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
@@ -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;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net,v2 1/2] net/mlx5e: fix memory leak in mlx5e_fs_tt_redirect_any_create
2023-06-30 1:49 ` [PATCH net,v2 1/2] net/mlx5e: fix memory leak in mlx5e_fs_tt_redirect_any_create Zhengchao Shao
@ 2023-06-30 3:18 ` Rahul Rameshbabu
0 siblings, 0 replies; 5+ messages in thread
From: Rahul Rameshbabu @ 2023-06-30 3:18 UTC (permalink / raw)
To: Zhengchao Shao
Cc: netdev, linux-rdma, davem, edumazet, kuba, pabeni,
richardcochran, saeedm, leon, lkayal, tariqt, gal, vadfed, ayal,
eranbe, weiyongjun1, yuehaibing
On Fri, 30 Jun, 2023 09:49:02 +0800 Zhengchao Shao <shaozhengchao@huawei.com> wrote:
> The memory pointed to by the fs->any pointer is not freed in the error
> path of mlx5e_fs_tt_redirect_any_create, which can lead to a memory leak.
> Fix by freeing the memory in the error path, thereby making the error path
> identical to mlx5e_fs_tt_redirect_any_destroy().
>
> Fixes: 0f575c20bf06 ("net/mlx5e: Introduce Flow Steering ANY API")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> Reviewed-by: Simon Horman <simon.horman@corigine.com>
> ---
> v2: update the 'any' member reference in fs to NULL before free fs_any
> ---
Thank you for contributing.
Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net,v2 2/2] net/mlx5e: fix memory leak in mlx5e_ptp_open
2023-06-30 1:49 ` [PATCH net,v2 2/2] net/mlx5e: fix memory leak in mlx5e_ptp_open Zhengchao Shao
@ 2023-06-30 13:22 ` Simon Horman
0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2023-06-30 13:22 UTC (permalink / raw)
To: Zhengchao Shao
Cc: netdev, linux-rdma, davem, edumazet, kuba, pabeni,
richardcochran, saeedm, leon, lkayal, tariqt, gal, rrameshbabu,
vadfed, ayal, eranbe, weiyongjun1, yuehaibing
On Fri, Jun 30, 2023 at 09:49:03AM +0800, Zhengchao Shao wrote:
> 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>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-06-30 13:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-30 1:49 [PATCH net,v2 0/2] fix two memory leak issues for mlx5en driver Zhengchao Shao
2023-06-30 1:49 ` [PATCH net,v2 1/2] net/mlx5e: fix memory leak in mlx5e_fs_tt_redirect_any_create Zhengchao Shao
2023-06-30 3:18 ` Rahul Rameshbabu
2023-06-30 1:49 ` [PATCH net,v2 2/2] net/mlx5e: fix memory leak in mlx5e_ptp_open Zhengchao Shao
2023-06-30 13:22 ` Simon Horman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.