* [PATCH net] net/mlx5: Don't use already freed action pointer
@ 2022-05-24 12:59 Leon Romanovsky
2022-05-28 5:28 ` Saeed Mahameed
0 siblings, 1 reply; 2+ messages in thread
From: Leon Romanovsky @ 2022-05-24 12:59 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski
Cc: Leon Romanovsky, Dan Carpenter, Eric Dumazet, linux-rdma,
Maor Gottlieb, Mark Bloch, netdev, Paolo Abeni, Saeed Mahameed
From: Leon Romanovsky <leonro@nvidia.com>
The call to mlx5dr_action_destroy() releases "action" memory. That
pointer is set to miss_action later and generates the following smatch
error:
drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c:53 set_miss_action()
warn: 'action' was already freed.
Make sure that the pointer is always valid by setting NULL after destroy.
Fixes: 6a48faeeca10 ("net/mlx5: Add direct rule fs_cmd implementation")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c
index 728f81882589..6a9abba92df6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c
@@ -44,11 +44,10 @@ static int set_miss_action(struct mlx5_flow_root_namespace *ns,
err = mlx5dr_table_set_miss_action(ft->fs_dr_table.dr_table, action);
if (err && action) {
err = mlx5dr_action_destroy(action);
- if (err) {
- action = NULL;
- mlx5_core_err(ns->dev, "Failed to destroy action (%d)\n",
- err);
- }
+ if (err)
+ mlx5_core_err(ns->dev,
+ "Failed to destroy action (%d)\n", err);
+ action = NULL;
}
ft->fs_dr_table.miss_action = action;
if (old_miss_action) {
--
2.36.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net/mlx5: Don't use already freed action pointer
2022-05-24 12:59 [PATCH net] net/mlx5: Don't use already freed action pointer Leon Romanovsky
@ 2022-05-28 5:28 ` Saeed Mahameed
0 siblings, 0 replies; 2+ messages in thread
From: Saeed Mahameed @ 2022-05-28 5:28 UTC (permalink / raw)
To: Leon Romanovsky
Cc: David S . Miller, Jakub Kicinski, Leon Romanovsky, Dan Carpenter,
Eric Dumazet, linux-rdma, Maor Gottlieb, Mark Bloch, netdev,
Paolo Abeni, Saeed Mahameed
On 24 May 15:59, Leon Romanovsky wrote:
>From: Leon Romanovsky <leonro@nvidia.com>
>
>The call to mlx5dr_action_destroy() releases "action" memory. That
>pointer is set to miss_action later and generates the following smatch
>error:
>
> drivers/net/ethernet/mellanox/mlx5/core/steering/fs_dr.c:53 set_miss_action()
> warn: 'action' was already freed.
>
>Make sure that the pointer is always valid by setting NULL after destroy.
>
>Fixes: 6a48faeeca10 ("net/mlx5: Add direct rule fs_cmd implementation")
>Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Applied to net-mlx5. I am still working on other critical fixes in my
net queue, will submit all at once next week so we can make it to rc1.
Thanks,
Saeed
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-28 5:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-24 12:59 [PATCH net] net/mlx5: Don't use already freed action pointer Leon Romanovsky
2022-05-28 5:28 ` Saeed Mahameed
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).