Re: [syzbot] [afs?] INFO: task hung in afs_cell_purge (2)
From: David Howells
Date: Tue Jun 16 2026 - 12:08:05 EST
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git v7.1
afs: Fix hang in afs_cell_purge()
Fix a hang in afs_cell_purge() due to net->cells_outstanding being updated
before the check for idr_alloc_cyclic() failing.
Reported-by: syzbot+750f21d691e244b473b1@xxxxxxxxxxxxxxxxxxxxxxxxx
Suggested-by: Hillf Danton <hdanton@xxxxxxxx>
Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
cc: Marc Dionne <marc.dionne@xxxxxxxxxxxx>
cc: linux-afs@xxxxxxxxxxxxxxxxxxx
diff --git a/fs/afs/cell.c b/fs/afs/cell.c
index 9738684dbdd2..e0fab1609f27 100644
--- a/fs/afs/cell.c
+++ b/fs/afs/cell.c
@@ -205,11 +205,11 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net,
cell->dns_source = vllist->source;
cell->dns_status = vllist->status;
smp_store_release(&cell->dns_lookup_count, 1); /* vs source/status */
- atomic_inc(&net->cells_outstanding);
ret = idr_alloc_cyclic(&net->cells_dyn_ino, cell,
2, INT_MAX / 2, GFP_KERNEL);
if (ret < 0)
goto error;
+ atomic_inc(&net->cells_outstanding);
cell->dynroot_ino = ret;
cell->debug_id = atomic_inc_return(&cell_debug_id);