From nobody Mon Apr 6 16:46:15 2026 Received: from sender-of-o59.zoho.eu (sender-of-o59.zoho.eu [136.143.169.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 989543DA7ED for ; Wed, 18 Mar 2026 16:48:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.169.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773852509; cv=pass; b=MBaNJGfh9Op3pNRofW1wBKUX8xacq4aBuQGslWQkUMSyvDqEBHbQOy/APrDD5g6/juHZG1T1F+HIjE2aphLGkK9uz/sE1pl28L+y0Tom8OPrY1rfgeSFbaMH5K++Uin9UPFXsI947C66uf97Mi/Rf17hc4Y+Y7P5HOUmfPj21nM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773852509; c=relaxed/simple; bh=smcHeb0hqulVxcQDHdkCV6GEDMY9lpJHk3GnSY26cUg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=qLcgnj7pMDLHExonpdpDnK3u5t89i5Iwbd0l186W0GxopnhCI0E1Z6JgVKE8rvH3/eRyqeAUy15wnUr8UPDMexb6xtQbjmS5CF15O01ee+6ZuTX0gSWSQdk/o4+jU825vJzub73lfwPzwOJtimrFH6CVVYPutfHxbtJMjTL1Seg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org; spf=pass smtp.mailfrom=objecting.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b=asIbHUW+; arc=pass smtp.client-ip=136.143.169.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=objecting.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=objecting.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=objecting.org header.i=objecting@objecting.org header.b="asIbHUW+" ARC-Seal: i=1; a=rsa-sha256; t=1773852498; cv=none; d=zohomail.eu; s=zohoarc; b=f1SYSGAZlnepSZ9FsQse2M++vdwrC/cR8/G01r6/5/zymGbLu2ofhvizyoWjtM9oiYGbGTE9EaMiareO7s1euaJco7Rx0u5IxSa4zGQYc+CTjvF+6uGRQ7QVkrM9uyTONG4Aei2QOZRoOMm2DJ/LndiQwAPp1wSIDRxMyhYp+L4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1773852498; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=cDDrHZmeHHqRrmzH89IdWsWKUGjDjWe1P08PleTf/sk=; b=Jnz4pZcsRNnUnFR225iSKZl+Hv9uZRPwksouR0fn3/bx8dYBuj0vRGxUM4pWFJnzqzGyVCtsWf43zfU0YrQDkF3icUtN+222yV7mUP2zKmkO3158/R5dAkRDFkly6Puq6nNetDnPpj5hcjGflrvhSnOsrJLHIKLvIM3L1qd9E4M= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=objecting.org; spf=pass smtp.mailfrom=objecting@objecting.org; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1773852498; s=zmail; d=objecting.org; i=objecting@objecting.org; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=cDDrHZmeHHqRrmzH89IdWsWKUGjDjWe1P08PleTf/sk=; b=asIbHUW+uv6ivxFzklI6YnU5uly2004zzbNrZaiFUYLbysUIe+vo7R5/Lc94GyC5 ClkhpOfDx81hDcgRsUtmOszhw++uorQQPp7pytb2aAA2r0XQdsfftdplCntENukRnR5 4Zk+rviOE9HYvKU1MbSxjkoKblgUBUvJpP+DqqOg= Received: by mx.zoho.eu with SMTPS id 177385249523558.903673253995976; Wed, 18 Mar 2026 17:48:15 +0100 (CET) From: Josh Law To: Andrew Morton Cc: Josh Law , linux-kernel@vger.kernel.org Subject: [PATCH] lib/assoc_array: fix stale nr_leaves_on_tree after gc Date: Wed, 18 Mar 2026 16:48:14 +0000 Message-Id: <20260318164814.85399-1-objecting@objecting.org> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External Content-Type: text/plain; charset="utf-8" In assoc_array_gc(), assoc_array_apply_edit() publishes the new tree root before nr_leaves_on_tree is updated, creating a window where the tree is visible with a stale leaf count. Move the nr_leaves_on_tree assignment before assoc_array_apply_edit() so the count is consistent when the new root becomes visible. Signed-off-by: Josh Law --- lib/assoc_array.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/assoc_array.c b/lib/assoc_array.c index bcc6e0a013eb..0752fd44e066 100644 --- a/lib/assoc_array.c +++ b/lib/assoc_array.c @@ -1711,8 +1711,8 @@ int assoc_array_gc(struct assoc_array *array, =20 gc_complete: edit->set[0].to =3D new_root; - assoc_array_apply_edit(edit); array->nr_leaves_on_tree =3D nr_leaves_on_tree; + assoc_array_apply_edit(edit); return 0; =20 enomem: --=20 2.34.1