* [bug report] net/mlx5: Replace fs_node mutex with reader/writer semaphore
@ 2021-08-25 9:58 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2021-08-25 9:58 UTC (permalink / raw)
To: maorg; +Cc: linux-rdma
[ This is not really the correct commit, but you seem like a person who
understands this locking. - dan ]
Hello Maor Gottlieb,
The patch c7784b1c8ab3: "net/mlx5: Replace fs_node mutex with
reader/writer semaphore" from Aug 27, 2017, leads to the following
Smatch static checker warning:
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c:336 down_write_ref_node()
warn: sleeping in atomic context
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
332 static void down_write_ref_node(struct fs_node *node, bool locked)
333 {
334 if (node) {
335 if (!locked)
--> 336 down_write(&node->lock);
337 refcount_inc(&node->refcount);
338 }
339 }
The call tree is this:
build_match_list() <- disables preempt
-> free_match_list()
-> tree_put_node()
-> down_write_ref_node()
The build_match_list() function takes rcu_read_lock(). What would make
the checker happy is if we did this. But it's not the correct fix
because locked is talking about &node->lock... Could you look at it and
give me a Reported-by cookie if you find a fix?
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index 9fe8e3c204d6..41ee18be1a3b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -1682,7 +1682,7 @@ static int build_match_list(struct match_list *match_head,
curr_match = kmalloc(sizeof(*curr_match), GFP_ATOMIC);
if (!curr_match) {
- free_match_list(match_head, ft_locked);
+ free_match_list(match_head, true);
err = -ENOMEM;
goto out;
}
regards,
dan carpenter
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-08-25 9:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-25 9:58 [bug report] net/mlx5: Replace fs_node mutex with reader/writer semaphore Dan Carpenter
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).