summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaor Gottlieb <maorg@nvidia.com>2021-09-01 11:48:13 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-09-22 12:26:41 +0200
commitcd78d9c9968f5ed8c044794e6a2612332f11cd53 (patch)
tree311d28da64fb1cb99dbfef516fcd4bd59b45ffb4
parent48e79555c22ce8aff3bdf2810dea1bd974a717c0 (diff)
net/mlx5: Fix potential sleeping in atomic context
commit ee27e330a953595903979ffdb84926843595a9fe upstream. Fixes the below flow of sleeping in atomic context by releasing the RCU lock before calling to free_match_list. build_match_list() <- disables preempt -> free_match_list() -> tree_put_node() -> down_write_ref_node() <- take write lock Fixes: 693c6883bbc4 ("net/mlx5: Add hash table for flow groups in flow table") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Maor Gottlieb <maorg@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fs_core.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index 739bf5dc5a25..5fe4e028567a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -1606,9 +1606,9 @@ static int build_match_list(struct match_list_head *match_head,
curr_match = kmalloc(sizeof(*curr_match), GFP_ATOMIC);
if (!curr_match) {
+ rcu_read_unlock();
free_match_list(match_head, ft_locked);
- err = -ENOMEM;
- goto out;
+ return -ENOMEM;
}
if (!tree_get_node(&g->node)) {
kfree(curr_match);
@@ -1617,7 +1617,6 @@ static int build_match_list(struct match_list_head *match_head,
curr_match->g = g;
list_add_tail(&curr_match->list, &match_head->list);
}
-out:
rcu_read_unlock();
return err;
}