From nobody Mon Apr 6 16:45:32 2026 Received: from sender-of-o58.zoho.eu (sender-of-o58.zoho.eu [136.143.169.58]) (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 A0A112D7BF for ; Wed, 18 Mar 2026 16:50:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.169.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773852610; cv=pass; b=BwnIeW2E6TJXs5ssmKXkC52OuRin6DJERQJ55M+jeUtZNLaMYbBBgpn+SnYlMiaX2aYMYGxqQCS2rBbvIpMCFpskHnTR8J7T3Ft04SJOWg/dVBVtjNTct3HAhdHXKbVumLNBFffNFvaPG/iYIYMc+2XH8zcjpNZ2jS9jbCjHvFE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773852610; c=relaxed/simple; bh=smcHeb0hqulVxcQDHdkCV6GEDMY9lpJHk3GnSY26cUg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=jKKgUWLVs63138ecZMBGFLcrTw5UeArZJYjH5LntqBTWRpDIaW4vNfHbL34M6ThF8aIzNsMjmJDMpNBtIB12qEQsODq8NWCxMwpzzJpwK3rrjXMepe2JvdzyOyuuTy80vMLhXIktvwgrxvY2DqzOcwujVqoN0aeYqodRLS/WYd0= 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=C/tgkoqG; arc=pass smtp.client-ip=136.143.169.58 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="C/tgkoqG" ARC-Seal: i=1; a=rsa-sha256; t=1773852604; cv=none; d=zohomail.eu; s=zohoarc; b=YPzIqSx3qKPRWxiRgrv+yzqh3XeIHrkn0kwNT+8GoVN64JMjJSRVRUhq3UPd13Zv36V7ix1ihUSOqM5updfacoWfaQuPvgHBfmi2kvwTts+8MoZxZ/IoVlUi5vyBObf09EFSWTPm110BbTXFEqkG3c9VusdRuhIyzI+dZwcrUlw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1773852604; 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=U+ZLhOJCDLRvcSuEbVrHm8L+DSkEYjiwvMkHPRZUZ4h9tFc8XZcHbz35HCfrGRv1fYVtkwKYxrJ+MQIediSOEXp+QhZQJMRoxe3phCWaXnmyH+yXFxVPXrqCHMN0bpMxkyCAfXz/k7PO3+D+AXJY4Sh243z+eFt+3reHicTe5mg= 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=1773852604; 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=C/tgkoqGYomEPaBviGkax/SCWgZ6z7NlmZL/C8nWv2UDsJem58Jhf2syg3bbgNm6 H4v+ko7YisvMai6NupEQW4V659IKdUo1IPRQCf+2B2yE9mBZjH2OrOEbPQSSvwPnm1S sAFW6qYrZxs15HFXgzHrMIGyafEHKeYqUlPD2ie4= Received: by mx.zoho.eu with SMTPS id 1773852600740112.38494787166997; Wed, 18 Mar 2026 17:50:00 +0100 (CET) From: Josh Law To: Andrew Morton Cc: Josh Law , linux-kernel@vger.kernel.org, hlcj1234567@gmail.com Subject: [PATCH] lib/assoc_array: fix stale nr_leaves_on_tree after gc Date: Wed, 18 Mar 2026 16:49:59 +0000 Message-Id: <20260318164959.85841-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