Skip to content

Commit 94fc256

Browse files
jlemongregkh
authored andcommitted
xdp: obtain the mem_id mutex before trying to remove an entry.
[ Upstream commit 86c76c0 ] A lockdep splat was observed when trying to remove an xdp memory model from the table since the mutex was obtained when trying to remove the entry, but not before the table walk started: Fix the splat by obtaining the lock before starting the table walk. Fixes: c3f812c ("page_pool: do not release pool until inflight == 0.") Reported-by: Grygorii Strashko <grygorii.strashko@ti.com> Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com> Tested-by: Grygorii Strashko <grygorii.strashko@ti.com> Acked-by: Jesper Dangaard Brouer <brouer@redhat.com> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bf22306 commit 94fc256

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎net/core/xdp.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,17 @@ static void mem_xa_remove(struct xdp_mem_allocator *xa)
8585
{
8686
trace_mem_disconnect(xa);
8787

88-
mutex_lock(&mem_id_lock);
89-
9088
if (!rhashtable_remove_fast(mem_id_ht, &xa->node, mem_id_rht_params))
9189
call_rcu(&xa->rcu, __xdp_mem_allocator_rcu_free);
92-
93-
mutex_unlock(&mem_id_lock);
9490
}
9591

9692
static void mem_allocator_disconnect(void *allocator)
9793
{
9894
struct xdp_mem_allocator *xa;
9995
struct rhashtable_iter iter;
10096

97+
mutex_lock(&mem_id_lock);
98+
10199
rhashtable_walk_enter(mem_id_ht, &iter);
102100
do {
103101
rhashtable_walk_start(&iter);
@@ -111,6 +109,8 @@ static void mem_allocator_disconnect(void *allocator)
111109

112110
} while (xa == ERR_PTR(-EAGAIN));
113111
rhashtable_walk_exit(&iter);
112+
113+
mutex_unlock(&mem_id_lock);
114114
}
115115

116116
static void mem_id_disconnect(int id)

0 commit comments

Comments
 (0)