diff mbox series

[bug,report] net/mlx5: Replace fs_node mutex with reader/writer semaphore

Message ID 20210825095811.GA32291@kili (mailing list archive)
State Not Applicable
Headers show
Series [bug,report] net/mlx5: Replace fs_node mutex with reader/writer semaphore | expand

Commit Message

Dan Carpenter Aug. 25, 2021, 9:58 a.m. UTC
[ 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?


regards,
dan carpenter
diff mbox series

Patch

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;
 		}