From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 892452DF6E6; Thu, 25 Jun 2026 13:08:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782392925; cv=none; b=DN+yM4qI5TNl7OsRDmFDK39K3q6uNWUC/HYjthMyNneHDQVvD32GbtI9Bd7vZ+64m3we9ikpsQN3oYAmqSm0Oioiuw9BvTjTp3IfgG4ZvCRCqon+08/pZX1kmE/m0Y3xh/dtQCmx8dy4TV9xPox0XB+pwQfzFg25KcRMYUG72p8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782392925; c=relaxed/simple; bh=LAH46GWgR5ng8bjt/UTyrKbrseYzajTJ4Zh7a0GXKBc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rwiQYbdcUiUf/koxvktzHEUZUaYdlvZ4oYtNJvyUgiRaJ8dWHslUt29BCJII8lTn0aTFPuPfC3dxKX7s/njDSklVGIwrdTJ8YntzcdUR5cceKfTTdKaWW7YhO4LwB0gqs6FuYvlXrHmoruA5h81jPlUNm/7iHlHT/DWjY1Z+izg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eJIz8C8A; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="eJIz8C8A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC16C1F000E9; Thu, 25 Jun 2026 13:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1782392922; bh=FEEo9GC8ufe6V8U2ruq/oUWMk4oKC4r+nIW1Xdtg8D8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eJIz8C8AbRdIHcY+wtAwKPwu0NZpTWcjojvB+AnomfBjLJpw2AunuRZN/q4VueFxE QylDv8rtMHvtyvrna+lIHKYBrpGvjfRV0b7tR1iaRTPrJMDFEbXMms51Te2fnVSn08 vlxu8+MUtpAKfECEM2PY83IE59FqI+6dOkTg1kWA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Georgi Djakov , "Oscar Salvador (SUSE)" , Vishal Verma , Mike Rapoport , Richard Cheng , David Hildenbrand , Georgi Djakov , "Rafael J. Wysocki" , Andrew Morton Subject: [PATCH 6.18 56/60] drivers/base/memory: set mem->altmap after successful device registration Date: Thu, 25 Jun 2026 14:03:41 +0100 Message-ID: <20260625125653.918941816@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260625125645.554579168@linuxfoundation.org> References: <20260625125645.554579168@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Georgi Djakov commit a2b8d7827f48ee54a686cb80e4a1d0ff954ec42a upstream. If __add_memory_block() fails at xa_store() (under memory pressure for example), device_unregister() is called, which eventually triggers memory_block_release() with mem->altmap still set, causing a WARN_ON(mem->altmap). This was triggered by modifying virtio-mem driver. Fix this by delaying the assignment of mem->altmap until after __add_memory_block() has succeeded. Link: https://lore.kernel.org/20260514092657.3057141-1-georgi.djakov@oss.qualcomm.com Fixes: 1a8c64e11043 ("mm/memory_hotplug: embed vmem_altmap details in memory block") Signed-off-by: Georgi Djakov Acked-by: Oscar Salvador (SUSE) Cc: Vishal Verma Cc: Mike Rapoport Cc: Richard Cheng Cc: David Hildenbrand Cc: Georgi Djakov Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/base/memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -828,7 +828,6 @@ static int add_memory_block(unsigned lon mem->start_section_nr = block_id * sections_per_block; mem->state = state; mem->nid = nid; - mem->altmap = altmap; INIT_LIST_HEAD(&mem->group_next); #ifndef CONFIG_NUMA @@ -846,6 +845,8 @@ static int add_memory_block(unsigned lon if (ret) return ret; + mem->altmap = altmap; + if (group) { mem->group = group; list_add(&mem->group_next, &group->memory_blocks);