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 ADFD52D0602; Thu, 2 Jul 2026 16:52:21 +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=1783011142; cv=none; b=Tlb+Wgt755BSc3npkHEXYfKSK41Ub2pJWmVYTD1/PvuXQFuWWPn8+vN2Nf1E+4lcw6ACT9b3Hl5vtmqaHi4sY2SaMxa2Zny6TmmZorJdkdA5T1fp9PjGlh4E/I5sB1PsrHGB5GXesmsZs+inDHYjEZ7FryTzMo2hQ5nUKAnYjNk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783011142; c=relaxed/simple; bh=0eJvJJ6k2JnfvVvMXQzleDQygD649YCm7ct13bFv1Q8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YDyxAqTov5ZywcZg2P8feZ71oIfP6VvUfRLR1vbna/jvAskA/mRrgPn158jt1AToM1QsNw73qISo7d8r+z57vVDhoefGQWLRRfnNbPVtaSoyBdCC/1xlbOMj3nmcW4fQWpyK+Wmf9FoztCBPtYIsU0iyNor800hIwzrYZ/gixQo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ViWHul0V; 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="ViWHul0V" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2347F1F000E9; Thu, 2 Jul 2026 16:52:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783011141; bh=yKUNY1LvVcgRl4hh+2+NWY70ecMF9P95Iztk3g4uv7Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ViWHul0VZ51kEsIE/SkCStfiEgBwIpLIlt4iGsnjbxKkAAzyT6YQLe70tW+zplYDJ vsi3041jKgRc1GgHiQdaSsW4sUsfxveS8WMtxAb1P9e2INwY9yeUOBZ042f5kyMXtf cNdNa6k65DS3hBrJ+vWE9iIhJeH2pJZ2OxHVHvg4= 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 , Sasha Levin Subject: [PATCH 6.6 171/175] drivers/base/memory: set mem->altmap after successful device registration Date: Thu, 2 Jul 2026 18:21:12 +0200 Message-ID: <20260702155119.385992188@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155115.766838875@linuxfoundation.org> References: <20260702155115.766838875@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Georgi Djakov [ Upstream commit a2b8d7827f48ee54a686cb80e4a1d0ff954ec42a ] 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: Sasha Levin 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 @@ -773,7 +773,6 @@ static int add_memory_block(unsigned lon mem->start_section_nr = block_id * sections_per_block; mem->state = state; mem->nid = NUMA_NO_NODE; - mem->altmap = altmap; INIT_LIST_HEAD(&mem->group_next); #ifndef CONFIG_NUMA @@ -791,6 +790,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);