* [PATCH net-next] net/mlx5: Fix memory leak in IPsec RoCE creation
@ 2023-02-19 12:59 Leon Romanovsky
2023-02-21 0:50 ` Jakub Kicinski
0 siblings, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2023-02-19 12:59 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski
Cc: Patrisious Haddad, Eric Dumazet, linux-rdma, Mark Zhang, netdev,
Paolo Abeni, Raed Salem, Saeed Mahameed
From: Patrisious Haddad <phaddad@nvidia.com>
During IPsec RoCE TX creation a struct for the flow group creation is
allocated, but never freed. Free that struct once it is no longer in use.
Fixes: 22551e77e550 ("net/mlx5: Configure IPsec steering for egress RoCEv2 traffic")
Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
.../ethernet/mellanox/mlx5/core/lib/ipsec_fs_roce.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/ipsec_fs_roce.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/ipsec_fs_roce.c
index 2c53589b765d..edc6798b359e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/ipsec_fs_roce.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/ipsec_fs_roce.c
@@ -162,7 +162,7 @@ int mlx5_ipsec_fs_roce_tx_create(struct mlx5_core_dev *mdev,
if (IS_ERR(ft)) {
err = PTR_ERR(ft);
mlx5_core_err(mdev, "Fail to create RoCE IPsec tx ft err=%d\n", err);
- return err;
+ goto fail_table;
}
roce->ft = ft;
@@ -174,22 +174,25 @@ int mlx5_ipsec_fs_roce_tx_create(struct mlx5_core_dev *mdev,
if (IS_ERR(g)) {
err = PTR_ERR(g);
mlx5_core_err(mdev, "Fail to create RoCE IPsec tx group err=%d\n", err);
- goto fail;
+ goto fail_group;
}
roce->g = g;
err = ipsec_fs_roce_tx_rule_setup(mdev, roce, pol_ft);
if (err) {
mlx5_core_err(mdev, "Fail to create RoCE IPsec tx rules err=%d\n", err);
- goto rule_fail;
+ goto fail_rule;
}
+ kvfree(in);
return 0;
-rule_fail:
+fail_rule:
mlx5_destroy_flow_group(roce->g);
-fail:
+fail_group:
mlx5_destroy_flow_table(ft);
+fail_table:
+ kvfree(in);
return err;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net-next] net/mlx5: Fix memory leak in IPsec RoCE creation
2023-02-19 12:59 [PATCH net-next] net/mlx5: Fix memory leak in IPsec RoCE creation Leon Romanovsky
@ 2023-02-21 0:50 ` Jakub Kicinski
2023-02-21 6:39 ` Leon Romanovsky
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2023-02-21 0:50 UTC (permalink / raw)
To: Leon Romanovsky
Cc: David S . Miller, Patrisious Haddad, Eric Dumazet, linux-rdma,
Mark Zhang, netdev, Paolo Abeni, Raed Salem, Saeed Mahameed
On Sun, 19 Feb 2023 14:59:57 +0200 Leon Romanovsky wrote:
> -rule_fail:
> +fail_rule:
> mlx5_destroy_flow_group(roce->g);
> -fail:
> +fail_group:
> mlx5_destroy_flow_table(ft);
> +fail_table:
> + kvfree(in);
> return err;
If you're touching all of them please name them after what they do.
Much easier to review.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net/mlx5: Fix memory leak in IPsec RoCE creation
2023-02-21 0:50 ` Jakub Kicinski
@ 2023-02-21 6:39 ` Leon Romanovsky
2023-02-21 16:30 ` Jakub Kicinski
0 siblings, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2023-02-21 6:39 UTC (permalink / raw)
To: Jakub Kicinski
Cc: David S . Miller, Patrisious Haddad, Eric Dumazet, linux-rdma,
Mark Zhang, netdev, Paolo Abeni, Raed Salem, Saeed Mahameed
On Mon, Feb 20, 2023 at 04:50:00PM -0800, Jakub Kicinski wrote:
> On Sun, 19 Feb 2023 14:59:57 +0200 Leon Romanovsky wrote:
> > -rule_fail:
> > +fail_rule:
> > mlx5_destroy_flow_group(roce->g);
> > -fail:
> > +fail_group:
> > mlx5_destroy_flow_table(ft);
> > +fail_table:
> > + kvfree(in);
> > return err;
>
> If you're touching all of them please name them after what they do.
> Much easier to review.
I can change it, but all mlx* drivers and randomly chosen place in ice
use label to show what fail and not what will be done. Such notation
gives an ability to refactor code without changing label names if
failed part of code is not removed.
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net/mlx5: Fix memory leak in IPsec RoCE creation
2023-02-21 6:39 ` Leon Romanovsky
@ 2023-02-21 16:30 ` Jakub Kicinski
0 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2023-02-21 16:30 UTC (permalink / raw)
To: Leon Romanovsky
Cc: David S . Miller, Patrisious Haddad, Eric Dumazet, linux-rdma,
Mark Zhang, netdev, Paolo Abeni, Raed Salem, Saeed Mahameed
On Tue, 21 Feb 2023 08:39:40 +0200 Leon Romanovsky wrote:
> On Mon, Feb 20, 2023 at 04:50:00PM -0800, Jakub Kicinski wrote:
> > On Sun, 19 Feb 2023 14:59:57 +0200 Leon Romanovsky wrote:
> > > -rule_fail:
> > > +fail_rule:
> > > mlx5_destroy_flow_group(roce->g);
> > > -fail:
> > > +fail_group:
> > > mlx5_destroy_flow_table(ft);
> > > +fail_table:
> > > + kvfree(in);
> > > return err;
> >
> > If you're touching all of them please name them after what they do.
> > Much easier to review.
>
> I can change it, but all mlx* drivers and randomly chosen place in ice
> use label to show what fail and not what will be done. Such notation
> gives an ability to refactor code without changing label names if
> failed part of code is not removed.
Please refactor, and it'd be great if the convention was changed for
all new code in these drivers.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-02-21 16:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-19 12:59 [PATCH net-next] net/mlx5: Fix memory leak in IPsec RoCE creation Leon Romanovsky
2023-02-21 0:50 ` Jakub Kicinski
2023-02-21 6:39 ` Leon Romanovsky
2023-02-21 16:30 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).